Skip to main contentSkip to footer

If you’re using custom post statuses, Relevanssi requires some tinkering. By default, Relevanssi only handles posts that are of status publish, pending, draft or private.

Relevanssi has a filter that lets you add more statuses to the list of acceptable statuses for Relevanssi. Add this to your site:

function rlv_add_status( $status_array ) {
    $status_array[] = 'new_status';
    return $status_array;
}
add_filter( 'relevanssi_valid_status', 'rlv_add_status' );
add_filter( 'relevanssi_valid_admin_status', 'rlv_add_status' );

This function, added to the two filters, makes Relevanssi accept the status new_status.

You also need to let search know that it’s ok to show these posts to users, using the relevanssi_post_ok filter hook:

add_filter( 'relevanssi_post_ok', 'rlv_allow_custom_status', 11, 2 );
function rlv_allow_custom_status( $post_ok, $post_id ) {
    $status = relevanssi_get_post_status( $post_id );
    if ( 'new_status' === $status ) {
      $post_ok = true;
    }
    return $post_ok;
}

With these functions, Relevanssi will now work with the status new_status.

Your account

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

Search

Popular Resources

Avada
Avada is one of the most popular WordPress themes on the market. All post types are not found Avada has…
Indexing HTML comments
By default, Relevanssi does not index HTML comments inside your posts. Relevanssi removes all HTML tags before indexing, and HTML…
Excluding protected posts

A site I’m working with has a handful of “protected” posts (password required to view). For various reasons, we don’t want to show these in search results. While there is no excerpt shown, I’d prefer for people to not even know they exist. Relevanssi sees protected posts as public posts……(because their post status is publish, not private like with private posts). That’s what they are, as, in general, users will be able to see protected posts. Just not their content unless they know the password. Relevanssi does protect the content and won’t show parts of it in excerpts. If……you want to deindex protected posts completely, add this code to your site: add_filter( ‘relevanssi_indexing_restriction’, ‘rlv_exclude_protected’ ); function rlv_exclude_protected( $restriction ) { global $wpdb; $restriction[‘mysql’] .= ” AND post.post_password = ””; $restriction[‘reason’] .= ‘ Has a password’; return $restriction; } Then just rebuild the index. This will prevent Relevanssi from…

Related Posts:

Comment Section:

4 Comments. Leave new

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