-
casadellalegalita
Hi,
I’m using GeneratePress and I would like to hide post meta (date and author) only for posts belonging to specific categories, while keeping them visible for all other posts.
For example:
– Category A → date and author hidden
– Category B / all other categories → date and author visibleIs there a recommended way to achieve this in GeneratePress?
I’m open to using hooks, filters, or custom CSS/PHP if needed.Thank you in advance for your help.
-
George
Please use the following PHP:
add_action( 'wp', function() { if ( has_category( array( 10, 20, 25 ) ) ) { add_filter( 'generate_post_date', '__return_false' ); add_filter( 'generate_post_author', '__return_false' ); } } );10,20and25being the category IDs you’re targeting. -
casadellalegalita
Thank you very much for your help!
The suggested solution works perfectly. I implemented the PHP code via a snippet and it now correctly hides the date and author only for posts in the documentation categories, while keeping them visible everywhere else.
Issue resolved 👍
Thanks again for the clear and effective support. -
George
Excellent, no problem!
- You must be logged in to reply to this topic.