0

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?

  • How do your show the author information? Add the code to your question. – fuxia Aug 19 '13 at 12:27
0

In 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()

  • It didn't worked. Perhaps because my theme is more complicated. Here is the code for bio box in single.php. Please have a look again: <div id="authorbox"> <div id="authorimg"> <?php $authoravatar = get_avatar( get_the_author_meta('email'), $size = '80'); ?> <?php if ($authoravatar !== NULL) { ?> <?php echo $authoravatar; ?> <?php } ?> </div> <div id="authorbioname"> <h2><?php the_author_posts_link(); ?></h2> </div> <div id="authorbio"> <p><?php the_author_meta('description'); ?></p> </div> <div id="authorsocial"> <?php $facebook = get_the_author_meta( 'facebook' ); ?> .... </div> </div> – Kaskarino Aug 19 '13 at 12:21
  • Have you tried embracing your parent div with the code I suggestd, like this: <?php if( is_author() ) : ?><div id="authorbox">...</div><?php endif; ?>? – Mayeenul Islam Aug 20 '13 at 8:19
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.