Viewing 10 replies - 1 through 10 (of 10 total)
  • eladyanai

    (@eladyanai)

    I’m having the exact same problem!
    Please update us.
    Thanks

    paultoon

    (@paultoon)

    Also having this problem. Worked fine until a week or so ago. Although content filter is set to show posts, category, tag and search pages are all now showing up.

    We’re also having this issue. One of our archive pages is showing up in the widget (see on the sidebar here, which currently shows ‘Cambodia Archives’).

    Is there a quick fix to exclude categories from appearing?

    Thank you

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Sorry for the inconvenience and the delay. This should be fixed in 1.6.8.

    Hi Justin,

    Thank you very much for the update. This works really well if you want to exclude posts from a certain category from appearing, but can it prevent category/archive pages from showing?

    I’ve just updated but we still have category pages on one of our sites.

    Thanks for your help!

    Plugin Author Justin Sternberg

    (@jtsternberg)

    To do that, you’ll have to use one of the built-in filters and put a snippet in your theme’s functions.php file. To remove specific paths, you can use this snippet:

    function gtc_pages_filter_manually_remove_items( $pages ) {
    
    	$page_paths_to_exclude = array(
    		'/category/category-slug',
    		'/category/2nd-category-slug',
    	);
    
    	foreach ( $pages as $index => $page ) {
    		if ( in_array( $page['path'], $page_paths_to_exclude, true ) ) {
    			unset( $pages[ $index ] );
    		}
    	}
    
    	return $pages;
    }
    
    add_filter( 'gtc_pages_filter', 'gtc_pages_filter_manually_remove_items' );

    If you want to remove all pages that start with “/category/” you could do that like this:

    function gtc_pages_filter_automatically_remove_items( $pages ) {
    
    	$string_to_exclude = '/category/';
    
    	foreach ( $pages as $index => $page ) {
    		// if path contains our excluded string, then remove it.
    		if ( false !== strpos( $page['path'], $string_to_exclude ) ) {
    			unset( $pages[ $index ] );
    		}
    	}
    
    	return $pages;
    }
    
    add_filter( 'gtc_pages_filter', 'gtc_pages_filter_automatically_remove_items' );

    Amazing, thank you very much for your quick response Justin. That has solved the problem.

    Cheers!

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Actually, I just pushed up a fix with 1.6.9. After looking further, when the filter options are used, there is no reason category archives should be showing up. I fixed the logic that was allowing that.

    It must be something to do with having a custom ‘category base’ (Settings > Permalinks). Your snippet worked nicely for our modified URL structure.

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Glad to know the snippet is working. With 1.6.9, the snippet is likely unnecessary if you have anything selected in the “Limit Listings To:” section.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to filter out categories?’ is closed to new replies.