Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There are certain posts on the website I'm developing, that don't need the author(s) by-line. (such as press releases)

Is there any method, that allows me to remove the author (and co-authors) for certain posts?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Thanks to mike23's suggestion, I solved my problem with conditional tags.


Just insert the following in the author area of single.php, archive.php and any other page template that displays an author.

<?php if ( has_tag('press_releases') ) {
      echo '';
} else { 
      echo 'by '; the_author_posts_link();
}
?>

Using the above code, you can remove the author name on all posts tagged press_releases.

All posts without the tag press_releases will retain their author name.

share|improve this answer
add comment

A quick fix would be to use WP's body class and in your stylesheet target the element containing the autor name to hide it for the page(s) you want.

For example :

.page-id-227 #my_authors{ display: none }

Update :

Another solution would be to use conditional tags in your templates, to print the author names only on wanted pages.

share|improve this answer
    
Thank you for informing me about the body class function. (it could be very useful for theme design) --- But if possible, I'd prefer to remove the author(s) from the page, rather then just hiding them from sight. --- The reason? Because these posts could still show up in search results for author names, even when I didn't want to associate any author with these articles. –  Ademos Jul 14 '11 at 7:48
    
@Ademos, what about conditional tags ? (see updated answer). ps. if you want to exclude posts from the search, you'll have to modify the search query, else they will show in results, no matter if the author name is displayed or not. –  mike23 Jul 14 '11 at 10:26
    
Thanks to your advice (and some Wordpress Codex examples) I was able to write the commands I needed. I created an answer for it, below. –  Ademos Jul 18 '11 at 5:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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