我想自动链接每个WordPress帖子的特色图片,只供访问者使用。因此,它不应该对WordPress的登录用户可用。它应该只链接single.php. 不适用于index.php, archive.php 或其他。
我有此代码,但不知道此代码应放在何处(WordPress中的哪个文件):
<?php
$image = get_the_post_thumbnail_url( $post->ID, \'large\' );
$link = is_user_logged_in() ? $image : \'https://example.com/\';
?>
也许我们可以把这个放进去
functions.php 或
single.php? 但当我把这个放进去的时候,它破坏了网站,或者什么都不做。