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

1 Answer 1

Reset to default 0

is_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