Need help with one line if php/html

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hausarzt
    Confirmed User
    • Jan 2011
    • 818

    #1

    Need help with one line if php/html

    Hey folks.
    I want to add an extra line of code to my wordpress site, but I can't fgure out the correct code. Maybe someone can help me?

    Every post has a featured image. I want to add a line of code, to that the the direct link to the featured image appears as a link in the theme.
    Must be something like

    Code:
    <a href='$postthumbnail-whatever-url' title='$thumbnail-title-or-so' target="_blank">CLICK HERE</a>
    Any helpers?
    I know, my english is bad. But your german might be even worse
  • zerovic
    Confirmed User
    • Apr 2010
    • 1116

    #2
    Try it like this
    <a href='<?php echo $postthumbnail; ?>-whatever-url' title='<?php echo $thumbnail; ?>-title-or-so' target="_blank">CLICK HERE</a>
    php, html, jquery, javascript, wordpress - contact me at contact at zerovic.com

    Comment

    • hausarzt
      Confirmed User
      • Jan 2011
      • 818

      #3
      If you mean this
      Code:
      <a href='<?php echo $postthumbnail; ?>' title='<?php echo $thumbnail; ?>' target="_blank">CLICK HERE</a>
      the answer is no.
      This code points to the post-url. A need to point it to the post-thumbnail-url.
      But we are getting closer.
      I know, my english is bad. But your german might be even worse

      Comment

      • machinegunkelly
        Confirmed User
        • Jun 2003
        • 3304

        #4
        // outside the loop
        Code:
            $post = get_post(99);
            $thumb_url = get_the_post_thumbnail_url($post->ID,'full'); 
        
            echo '<a href="'.esc_url($thumb_url).'">Click Here</a>';
        // inside the WP loop

        Code:
            while ( have_posts() ) {
                the_post(); 
                $thumb_url = get_the_post_thumbnail_url(get_the_ID(),'full'); 
                echo '<a href="'.esc_url($thumb_url).'">Click here</a>';
            endwhile;
        dead.

        Comment

        Working...