Skip to main contentSkip to footer

PublishPress Revisions causes duplicates to appear in Relevanssi search results when a revision is approved.

When the revision is created, Relevanssi indexes it because it has the same post type as the original post with the post status draft. Relevanssi indexes drafts because people may want to search for them in the admin search. This is all fine because the draft post isn’t visible in the search.

When the revision is approved, the post type changes to revision and the post status changes to inherit (and the parent has publish, so that’s what the revision inherits) Relevanssi should not index revisions; that’s why reindexing helps. However, the status change happens in a way Relevanssi doesn’t notice, so now Relevanssi sees there’s a post with publish status, and it can be shown in the search results.

Add this to your site to fix this problem:

add_action( 'revision_applied', function( $published, $revision ) {
    relevanssi_remove_doc( $revision->ID );
}, 10, 2 );

This will make Relevanssi deindex the revision when it’s approved.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Using AND and NOT for Boolean operators

Relevanssi Premium has support for in-query Boolean operators. Relevanssi uses + and – for the operators: cats -dogs and cats +kittens. If you prefer instead to use the verbal AND and NOT operators, it only takes one small function. Add this to your site: add_filter( ‘relevanssi_search_filters’, ‘rlv_boolean_operators’ ); function rlv_boolean_operators(…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed