• Resolved birdhousedigital

    (@birdhousedigital)


    I am using your Post Grid and want to exclude one category but there’s no option to do so. I saw a previous support enquiry asking the same, from a few years ago. The solution posted in that discussion does not seem to work, possibly because Spectra has had a major update since then?

    I’d love to know if you have a filter I can use to exclude a particular category from the Post Grid.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support BSF- Mohsin Ghouri

    (@mohsinbsf)

    Hi @birdhousedigital,

    Thanks for getting in touch with us.

    You can achieve your desired goal by using uagb_post_query_args_grid filter. For more information, you can check this guide: https://wpspectra.com/docs/filters-actions-for-post/

    Please try and let me know how it goes.

    Have a nice day!

    Thread Starter birdhousedigital

    (@birdhousedigital)

    Thank you. I was trying the following but it doesn’t seem to work?

    function filter_post_query( $query_args, $attributes) {
    if ( ‘media-post-grid’ == $attributes[‘className’] ) {
    $query_args[‘post__not_in’] = array( 1, 89 );
    }
    return $query_args;
    }
    add_filter( ‘uagb_post_query_args_grid’, ‘filter_post_query’, 10, 2 );

    Plugin Support BSF- Mohsin Ghouri

    (@mohsinbsf)

    Hi @birdhousedigital,

    It seems you are removing specific posts from the query, however, in your first message you had mentioned to exclude specific category. Please let me know if you have changed your mind. And please also note that, you have to change the className from the above code to the class name that you added in the block from the block settings.

    Looking forward to hearing from you.

    Have a nice day!

    Thread Starter birdhousedigital

    (@birdhousedigital)

    Oh yes I see! I got mixed up. Finally got it working with the following

    function filter_post_query( $query_args, $attributes) {
    // Unique class name added from Advanced tab for Post Grid.
    if ( ‘media-post-grid’ == $attributes[‘className’] ) {
    // 1 is the category id you want to exclude.
    $query_args[‘category__not_in’] = array( 1,89 );
    }
    return $query_args;
    }
    add_filter( ‘uagb_post_query_args_grid’, ‘filter_post_query’, 10, 2 );

    Thanks for your help!

    Plugin Support BSF- Mohsin Ghouri

    (@mohsinbsf)

    Hi @birdhousedigital,

    Thanks for letting us know.

    I’m glad it works out for you.

    Please feel free to open a new thread if you face any other issue.

    Have a nice day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Post Grid – exclude category’ is closed to new replies.