• Resolved PBPFX827

    (@pbpfx827)


    I have used the code snippet to filter related post category that you provide but I was wondering if there is a code snippet to remove multiple categories?

    My goal is to show related posts from one specific category only but I am not seeing this as an option in the code snippets you provide. I also tried to add a second category but it breaks the coding – so hence my query on this forum.

    https://wordpress.org/plugins/jetpack/

Viewing 1 replies (of 1 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    This should help:

    function jetpackme_filter_exclude_categories( $filters ) {
    	$filters[] = array( 'not' =>
    		array( 'terms' => array( 'category.slug' => array( 'cat-1', 'cat-2', 'cat-3' ) ) )
    	);
    	return $filters;
    }
    add_filter( 'jetpack_relatedposts_filter_filters', 'jetpackme_filter_exclude_categories' );
Viewing 1 replies (of 1 total)

The topic ‘Customising Related Posts’ is closed to new replies.