• Resolved matthewstringer

    (@matthewstringer)


    Hi all, I am trying to add a filter to Jetpack so that related posts will only come from a group of posts with a specific tag. In other words, pick any random post on the site, its related posts will just be any three of about a dozen posts with a specific tag. Is this possible? Thank you in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor James Huff

    (@macmanx)

    We don’t have an option for that yet. The closest we have is an option to exclude specific categories: https://jetpack.com/support/related-posts/customize-related-posts/#exclude-cats

    Thread Starter matthewstringer

    (@matthewstringer)

    Thanks, James. I figured out how to exclude multiple categories, and was able to move the posts needed for related posts in to a separate category. However, none of those posts are appearing now. There are only about a dozen if that matters. I tried to force-reindex the site in wordpress.com, but they still won’t show. Does it just take time or are there not enough posts to pull from? Thanks in advance!

    Plugin Contributor James Huff

    (@macmanx)

    About how long ago did you force the re-index? It can take about 24 hours to complete.

    Thread Starter matthewstringer

    (@matthewstringer)

    Only about an hour ago. Because of the nature of the site, I am reverting to showing more categories and will attempt to resolve with the new category when traffic dies down overnight. I will follow up! Thanks again.

    Plugin Support darnelldibbles

    (@darnelldibbles)

    Yes. definitely keep us updated. Thanks!

    Thread Starter matthewstringer

    (@matthewstringer)

    Hi all, yes, the change worked actually rather quickly. So, to summarize, I used the exclusion code snippet you guys provided elsewhere in my functions.php file, like so:

    function jetpackme_filter_exclude_category( $filters ) {
        $filters[] = array(
            'not' => array(
                'terms' => array(
                    'category.slug' => array(
                        'category1',
                        'category2',
    	            'category3',
    		    'uncategorized'
                    ),
                ),
            ),
        );
        return $filters;
    }
    add_filter( 'jetpack_relatedposts_filter_filters', 'jetpackme_filter_exclude_category' );

    By way of background, categories 1-3 are the ones I wanted to exclude. Then, the category of those unique, dozen or so posts, let’s call it category 4, was not excluded and thus it became the only batch of posts to pull related posts from. I just had to make sure it did not share a category with any of the others.

    Speaking verbosely to help future web denizens who wind up here. Thanks again!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Related Posts – only pull from specific tag’ is closed to new replies.