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?
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?
Share Improve this question asked May 31, 2019 at 18:55 vordinerdovordinerdo 54 bronze badges 1- Are you using your own theme? You'll just need to change the link in the template. – Jacob Peattie Commented Jun 15, 2019 at 7:52
1 Answer
Reset to default 0In 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/">';
}
the_post_thumbnail();
if ( is_user_logged_in() ) {
echo '</a>';
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745446620a4628076.html
评论列表(0条)