0

I want to link featured images of every WordPress posts to specific page/url for only visitors (non-logged in members). And this function should be disabled for logged in users. It should only link featured images of single.php. Not for index.php, archive.php or others. How to do?

  • Are you using your own theme? You'll just need to change the link in the template. – Jacob Peattie Jun 15 '19 at 7:52
0

In single.php you can wrap your featured image in a link tag with a conditional to check if the user is logged in.

    if ( is_user_logged_in() ) {
        echo '<a href="https://google.com/">';
    }

    the_post_thumbnail();

    if ( is_user_logged_in() ) {
        echo '</a>';
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.