I am trying to find how all posts of a specific author will appear without the author box, while all the others authors posts will have their author boxes.
Can somebody help me with this?
I am trying to find how all posts of a specific author will appear without the author box, while all the others authors posts will have their author boxes.
Can somebody help me with this?
Share Improve this question asked Aug 19, 2013 at 10:20 KaskarinoKaskarino 11 bronze badge 1- How do your show the author information? Add the code to your question. – fuxia ♦ Commented Aug 19, 2013 at 12:27
2 Answers
Reset to default 1In my theme with raw codes, Post Meta Data are shown like:
<div class="entry-meta">
<span class="meta-prep meta-prep-author"><?php _e('By ', 'your-theme'); ?></span>
<span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( 'View all posts by %s', 'your-theme' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span>
</div><!-- .entry-meta -->
It displays the meta data like:
Post Content here like Lorem Ipsum is simply dummy text of the printing and typesetting industry. ____________________________________________ by Author_name
In my case, you can simply put a conditional tag like:
<?php if( !is_author( 'author_nickname' ) ) : ?>
<div class="entry-meta">
...
</div>
<?php endif; ?>
Note: I enabled the meta-box for all author, except someone. I put the author_nickname
here, you can put the author_id
too. Check the Codex:
Codex: Function Reference:is_author()
First of all I'd recommend to use a child theme and leave behind the original theme, this way you wouldn't lose any customizations when updating your theme.
Then, if you're actually using a child theme, just copy to your child theme directory this single.php
, and wrap the author div
with this:
if ( get_post_field( 'post_author', get_queried_object_id() ) != $author_id) :
...
endif;
... where $author_id
is the ID of the author you want to hide the block.
The other way depends on how works your theme, if the author div
is handle by a function, look for it in the *functions.php
of your theme, and copy it to your functions.php
(in your child theme directory) and do the mentioned modification.