Site Overlay

WordPress. How To Exclude Category From Displaying On Blog Page

This tutorial is going to show you how to exclude category from displaying on Blog page in WordPress themes.

TOP WordPress Themes:

To view more our WordPress templates go to website:

More WordPress Video Tutorials:

Want to Build WordPress Site in 5 Hours? Subscribe to this course:

Subscribe Our Channel:

Follow us:


Xem thêm bài viết:

9 thoughts on “WordPress. How To Exclude Category From Displaying On Blog Page

  1. The code here wasn't working for me, but I found a similar one that did:

    add_filter('pre_get_posts', 'excludeCat');
    function excludeCat($query) {
    if ( $query->is_home ) {
    $query->set('cat', '-20');
    return $query;

  2. You mention a text tutorial where we can grab the code. Can you provide a link, please? Thanks!

  3. Update code to Wp v5.0.2 is: function exclude_category($query) {


    $query->set('cat', '-42, -43');


    return $query;


    add_filter('pre_get_posts', 'exclude_category');

  4. Thanks for this video, it works, my problem is I only want to esclude the category from my blog, but I want it to be shown in the other pages, with this code it gets hidden from everywhere 🙁 any solution?

Leave a Reply

Your email address will not be published. Required fields are marked *