admin管理员组文章数量:1406950
I'd like to display some information inside a div on the single posts written by some authors. For exemple, author ID 15 has 100 posts. I'd like to display some information on that post pages, just below the header. I've tried this but it didn't work.
<?php if ( is_author( '15' ) ) : ?>
<div class="specialist"><img src=".png" /> Specialist: <?php the_author_posts_link(); ?></div>
<?php endif; ?>
I'd like to display some information inside a div on the single posts written by some authors. For exemple, author ID 15 has 100 posts. I'd like to display some information on that post pages, just below the header. I've tried this but it didn't work.
<?php if ( is_author( '15' ) ) : ?>
<div class="specialist"><img src="https://xxxxxx.br/wp-content/uploads/2019/11/xxxx.png" /> Specialist: <?php the_author_posts_link(); ?></div>
<?php endif; ?>
Share
Improve this question
asked Dec 5, 2019 at 19:00
juniorbrajuniorbra
413 bronze badges
1 Answer
Reset to default 0is_author()
isn't working as you expect because it checks whether the current query is for an existing author archive page.
If you're placing your code in single.php
inside the loop, you can use this instead:
<?php if( $post->post_author == '15' || $post->post_author == '16' ) { ?>
<div>Your code here</div>
<?php } ?>
本文标签: conditional tagsDisplay a div only in some author39s single posts
版权声明:本文标题:conditional tags - Display a div only in some author's single posts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744934893a2633123.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论