• Resolved petej830

    (@petej830)


    I have a blog were I post the headlines in the news from other sites(like a news feed). Since I did not write the article I don’t want my name to show up as the author. I do however have contributes that post original articles and I wan’t there name to show in there post. I already know how to hide author info completely but I want it to show when contributors write. Is there anyway to hide author info just when certain member post story’s?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Do you need to remove more than just the author? For example, if you have this “author | Posted on xxxx/xx/xx” do you need to remove all of it or just the ‘author’? If the later you can probably do it with a filter, if the former you most likely need to edit your theme.

    Thread Starter petej830

    (@petej830)

    I just need the “author” not to show. I looked everywhere for a plugin that would do it but I’ve found nothing. I was hoping for a plugin that would show when I’m adding a new post and I can check it if I want to hide the author. They do have “Post Anonymous” plugin but all that does is say the author is “anonymous”. If I click on “anonymous” it takes you to the users profile that is trying to stay anonymous, so that didn’t work to good. I know this is a tough one because not to many people would need something like this. But if anybody has any ideas please let me know. I was thinking some type of code that said “if posted by this user then hide author” That’s what I need. I’ve been battling this issue for a couple of weeks now.

    It isn’t hard to filter particular users, actually. In your theme’s functions.php :

    function hide_admin_author($author) {
      if ('admin' !== $author) return $author;
    }
    add_filter('the_author','hide_admin_author');

    If your admin author shows up as ‘admin’, that will hide it. You can edit the conditional or cook up more complicated logic if you need to.

    This isn’t the plugin with a check box you mentioned but maybe it will help.

    Thread Starter petej830

    (@petej830)

    Awesome! Thank you s_ha-dum that actually! I figured it would be a simple code you could put in. Now if I want to do if for multiple members not just the admin do I do the same code just change where it says “admin” to whatever the other members names are?

    function hide_editor_author($author) {
    if (‘User Name’ !== $author) return $author;
    }
    add_filter(‘the_author’,’hide_editor_author’);

    do the same code twice? One other think that’s not a big deal is now it has “By On July 22, 2012 Add Comment” is there a way to take the “By” out?

    You can make a more complicated conditional.

    function hide_admin_author($author) {
      if (
           ('admin' !== $author) &&
           ('user1' !== $author) &&
           ('user2' !== $author)
      ) return $author;
    }
    add_filter('the_author','hide_admin_author');

    That code is overly formatted but more readable with the extra parenthesis. It means “if ‘admin’ is not the author name and ‘user1’ is not the author name and ‘user2’ is not the author name, then return the author name.” If all of the conditions are true it will print the author. If even one of them is false the whole thing is false.

    Thread Starter petej830

    (@petej830)

    Awesome that worked great! You’ve been a big help. Thank you

    I’m trying to solve a similar issue. Hiding the author info if a certain category is selected for the post.

    I have tried the solution s_ha_dum suggested, but the “By” just before the author’s name is still visible. Where can I edit that out?

    Thanks.

    I have the same issue johnkwhite has. Is there a way to hide specific metadata from a specific category??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Hide author info when admin post’ is closed to new replies.