WordPress.org

Forums

Want to add related link & image to bottom of posts by Tag... (4 posts)

  1. kk4uga
    Member
    Posted 3 years ago #

    I want WP to automatically add an image and then a link to the single.php based on the Tag or Tags in the post. Can this be accomplished?

    This is similar to a Related Posts feature, but I want to try and link to a specific page (with an image to the left of the link) each time.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    It should be possible using get_the_tags. Something like:

    <?php
    $posttags = get_the_tags();
    if ($posttags && in_array( 'wibble',$posttags) ) :>
    [ output image & link ]
    endif;?>

    should work within the Loop.

  3. kk4uga
    Member
    Posted 3 years ago #

    Thanks.

    How do I specify which tag and which image to pull in?

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Replace wibble with the tag that you want to use. As for which image to use - that's up to you.

Topic Closed

This topic has been closed to new replies.

About this Topic