Site logo

[Resolved] Calendar for specific category

Home Forums Support [Resolved] Calendar for specific category

Home Forums Support Calendar for specific category

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2546188
    Masud

    Currently the calendar showing all category posts. How to show only a specific category post?

    #2546444
    David
    Staff
    Customer Support

    Hi there,

    which calendar ? Can you share a link to where i can see this on your site ?

    #2546745
    Masud

    I’m actually using Widget > Calendar –

    #2547318
    David
    Staff
    Customer Support

    OK, so that generates links to date archives.
    And you can use a PHP Snippet to set the cat query to the ID of a single category:

    function exclude_category_from_archives( $query ) {
        if ( $query->is_date() && $query->is_main_query() ) {
            $query->set( 'cat', '99' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category_from_archives' );
    

    Replace 99 with the id of your category.

    NOTE: This will not change what the calender displays, that is a core Block, and they did not add any filters hooks ( to my knowledge ) to change what it displays.

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