GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Need help with one line if php/html (https://gfy.com/showthread.php?t=1326986)

hausarzt 04-26-2020 01:21 AM

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?

zerovic 04-26-2020 06:57 AM

Try it like this
Quote:

<a href='<?php echo $postthumbnail; ?>-whatever-url' title='<?php echo $thumbnail; ?>-title-or-so' target="_blank">CLICK HERE</a>

hausarzt 04-26-2020 08:23 AM

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.

machinegunkelly 04-28-2020 11:18 AM

// 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;

:2 cents:


All times are GMT -7. The time now is 07:53 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc