• Hi, I am trying to exclude posts with the custom post status “archive”. I’ve tried excluding the post status via a Jetpack hook but it doesn’t work, also I’ve added the category “archived” to all post with the post status of “archive” and then tried excluding that post category, it still does not work – these Archived posts still show up in related posts.

    I’ve tried to exclude a custom post status:

    function jetpackme_filter_exclude_category( $filters ) {
        $filters[] = array( 'not' =>
          array( 'term' => array( 'post_status' => 'archive') )
        );
        return $filters;
    }
    add_filter( 'jetpack_relatedposts_filter_filters', 'jetpackme_filter_exclude_category' );

    and I’ve tried to exclude a category. Only posts with post status “archived” will have this category.

    function jetpackme_filter_exclude_category( $filters ) {
        $filters[] = array( 'not' =>
          array( 'term' => array( 'category.slug' => 'archived') )
        );
        return $filters;
    }
    add_filter( 'jetpack_relatedposts_filter_filters', 'jetpackme_filter_exclude_category' );

    I shouldn’t rely on post category here but I would really like to exclude the post_status if I can?

    https://www.ads-software.com/plugins/jetpack/

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

    (@jeherve)

    Jetpack Mechanic ??

    Could you tell me more about that custom Post Status? When you registered it, what arguments did you use? is that post status marked as public, or internal?

    If the archive status isn’t marked as public, the posts shouldn’t appear in your Related Posts.

    It would also help if you could give me a few examples of posts that appear in Related Posts, when they shouldn’t.
    If you want your site URL to remain private, you can also contact us via this contact form:
    https://jetpack.com/contact-support/

Viewing 1 replies (of 1 total)
  • The topic ‘Related Posts – How to exclude a custom post status’ is closed to new replies.