Posted on

PublishPress Revisions: duplicate posts

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.

Leave a Reply

Are you a Relevanssi Premium customer looking for support? Please use the Premium support form.

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