Screenshot showing 'Posted in Uncategorized'

I made one blog post page and 2 second page I made for uncategorized category page using this file category-uncategorized.php and now I want to remove this all uncategorized category from blog page.

and here is a code

<?php if(have_posts()) :
    while (have_posts()) :
        get_template_part('content', get_post_format());
    <?php echo bootstrap_pagination($query) ?>
<?php else :
    echo '<p>No Content Found</p>';
  • When you say you "made one blog post page" do you mean you made a Page in wp-admin and you are showing all the Posts within that Page? Or do you just mean you created a Post in the Uncategorized Category, and now that post is showing up on your front page a.k.a. the "Posts page"? In either case you could use pre_get_posts to change the query on whichever URL you are talking about, to exclude that category.
    – WebElaine
    Jun 26 '19 at 13:12

Please try code given below:

function blog_exclude_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'cat', '-1' );
add_action( 'pre_get_posts', 'blog_exclude_category' );

Add this in your functions.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.