Site logo

Archived topic

Removing Default Column Posts from Category

5 replies · Started by Mihail on October 20, 2022

Viewing posts 1–6 of 6

Hello,

I am struggling to remove the 3 columns and the default category posts from a specific category page.

I just want the Block - Page Hero element I created to appear on the specific category page. I posted the URL of the category below. How do I do this?

Any help will be appreciated,
Mihail.

Hi there,

try adding this PHP Snippet to your site:


add_filter( 'generate_has_default_loop', function($loop){
    if ( is_category( 'no-surgery' ) ) {
        $loop = false;
    }
    return $loop;
} );

Make sure the the no-surgery is the correct category slug.

Hello David, thank you for the reply.

I added the PHP Snippet to my site, and it successfully removed the columns. However, it removed the 3 columns and the default category posts from all of my category pages, not just the category with no-surgery slug.

What should I do next to correct this?

Thank you,
Mihail.

Doh! - i updated the code above to fix a stupid error...

Thank you David for the fast reply.

This corrected the issue. Thanks a lot.

Awesome - glad to be of help!

This archived topic is closed to new replies.