functions - How to link all featured images to custom url in single.php for only non-logged-in users?

I want to link featured images of every WordPress posts to specific pageurl for only visitors (non-logged in members).

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
Add a comment  | 

1 Answer 1

Reset to default 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/">';
    }

    the_post_thumbnail();

    if ( is_user_logged_in() ) {
        echo '</a>';
    }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745446620a4628076.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信