WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Hide Post Author & Date – specific issue…

[Resolved] Hide Post Author & Date – specific issue…

  • Hello,

    I am trying to get WordPress to hide author, date, and the “bookmark the permalink” – but ONLY in posts of a certain category. I know how to do a universal site-side change of this, but I don’t want to hide this data from other blog posts and categories, just a particular category.

    Is this possible? Can you please tell me what code I’d need to adjust for this? Thank you so much. I can’t complete my job here unless I solve this…

Viewing 15 replies - 1 through 15 (of 49 total)
  • you would have to make a conditional logic function something like

    if(is_category(id1,id2, id3)
    {
    hide info
    }

    Assuming I knew the category ID (which I know how to find), what file would I enter that code into? If it’s just one category and not all pages/posts…

    Also, when you write “hide info”, what actually goes in between the {} in that example? Like, “entry-author” ? I’m a bit confused.

    Thank you so much for trying to help me, you’re a true lifesaver.

    How should I proceed?

    it will go into your functions.php file (preference would be if you create a child theme and not modify the core files)

    i usually do for hide info thing is use css
    <?php
    if (is_category(‘id’))
    {
    echo ‘ <style> #author {display:none;} #time {display:none;}
    </style>’;
    }
    ?>

    Thank you Robin, I will try that code and mess around with it. If this works, I’ll hurry back and let you know that you saved the day.

    I wish I was a guru like so many people here are 🙂

    Thanks again,
    Ben

    cheers

    Hmm…is there a particular location in the functions file that this code should go in? Like, between other code, or at the very end, or etc.

    Thank you!

    i put my code on top

    Well, no matter where I seem to place it in the php file, I get this sort of error:

    Parse error: syntax error, unexpected ‘<‘

    I’m copying your code exactly, so perhaps I’m putting it in the middle of some code I should not be breaking up?

    Is there a surefire way to know where I can put it where it will be safe and work correctly?

    Thank you!

    my code was just a reference guide
    and if you are getting this error means you are not closing your tags properly or missing a bracket
    and if you put it on top under your
    <?php ?>
    it should not break

    Ah, yes ok – I thought I maybe forgot to close off the PHP with ?> or something – but it looked right.

    I’ll try and put it at the top under the <?php ?> – thanks again!

    <?php
    if ( is_user_logged_in()  )
      {
       echo ' <style>
    
    	</style>';
    } else {
    
    	echo ' <style>
    
    	html {
        background-color:#FFF !important;
    }
    
    	</style>' ;
    }
    ?>

    this is my working code

    …? You lost me… 🙂

    i mean if you follow the structure of my code it should work , as this is the code i am using in one of my sites

    Ah, yes – good news. The code no longer has a syntax error, but it doesn’t hide any data – so maybe the CSS does not match?

    if (is_category(’23’))
    {
    echo ‘ <style> #author {display:none;} #time {display:none;}
    </style>’;

    This doesn’t return an error but the author and time are still showing up in that category for posts.

    Hmmm…any ideas? You seriously are saving my tail here…

Viewing 15 replies - 1 through 15 (of 49 total)
  • The topic ‘[Resolved] Hide Post Author & Date – specific issue…’ is closed to new replies.