Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Disable date and author only for posts in specific categories

  • 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 visible

    Is 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.

  • 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, 20 and 25 being 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.

  • Excellent, no problem!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.