Forum Replies Created

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter superluckydi

    (@superluckydi)

    Thanks for your patience!

    I now have this code:

    function jetpackme_filter_exclude_categories( $filters ) {
    	$filters[] = array( 'not' =>
    		array( 'terms' => array( 'category.slug' => array( 'competitions', 'instant-wins-daily-draws', 'superlucky-giveaways', 'latest-competitions', 'blog-comp-linky'  ) ) )
    	);
    	return $filters;
    }
    add_filter( 'jetpack_relatedposts_filter_filters', 'jetpackme_filter_exclude_categories' );

    On the same post, I still have two posts from the ‘Latest competitions’ category’ showing: https://superlucky.me/2015/03/budweiser-dream-goal-promotion/

    Thanks!

    Thread Starter superluckydi

    (@superluckydi)

    Thanks Jeremy. I’m using the ‘Edit functions’ plug in, this is what I have in the file:

    function jetpackme_related_posts_headline( $headline ) {
    $headline = sprintf(
                '<h3 class="jp-relatedposts-headline"><em>%s</em></h3>',
                esc_html( 'If you liked this, you might enjoy these...' )
                );
    return $headline;
    }
    add_filter( 'jetpack_relatedposts_filter_headline', 'jetpackme_related_posts_headline' );
    
    function jetpackme_filter_exclude_category( $filters ) {
        $filters[] = array( 'not' =>
          array( 'term' => array( 'category.slug' => 'competitions' ) )
        );
        return $filters;
    }
    add_filter( 'jetpack_relatedposts_filter_filters', 'jetpackme_filter_exclude_category' );

    I’ve gone back to trying to exclude all posts from just one main category – competitions – which has 4 sub categories. As an example, my latest post at https://superlucky.me/2015/03/carhireoke-castles-kent/ is showing two related posts from the competitions category (one in the ‘latest comps’ sub category, one in ‘blog comp linky’ sub category). This post is also showing two related posts from ‘latest comps’ – https://superlucky.me/2015/03/budweiser-dream-goal-promotion/. I also tried replacing ‘competitions’ with ‘latest-competitions’ but that didn’t work.

    Thanks for your help!

    Thread Starter superluckydi

    (@superluckydi)

    Thanks for your input Jeremy. I still can’t get this to work. I specifically want to exclude all posts in the ‘https://superlucky.me/category/competitions/&#8217; category, which contains 4 sub categories. I’ve tried excluding the single ‘competitions’ category slug in the original code I posted, and using the 4 individual sub categories in the code you’ve given me above, but still my posts show related posts from the ‘latest competitions’ category at the bottom!

    (I’ve deactivated the plug in at the moment as I don’t want people clicking on those out-of-date posts!)

Viewing 3 replies - 16 through 18 (of 18 total)