Skip to main contentSkip to footer

Are post ID’s searchable in Relevanssi?

No. Relevanssi does understand the WP_Query p parameter to restrict the search by post ID.

However, if you want to search by post ID, it’s very simple to make that happen using the relevanssi_content_to_index filter hook:

add_filter( 'relevanssi_content_to_index', 'rlv_index_post_id', 10, 2 );
function rlv_index_post_id( $content, $post ) {
    $content .= ' ' . $post->ID;
    return $content;
}

Add that to theme functions.php, reindex and searching for post ID’s works.

Originally asked here.

Your account

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

Search

Popular Resources

Multi-part excerpts

…the search term appear only once in the document, there’ll be fewer excerpts. Relevanssi also tries to avoid overlapping excerpts and will eliminate excerpts that look too much like excerpts it has already chosen. The different parts will be combined together in the order of relevance: the best part comes……knows that and you can display that information on the search results page: Achieving this is a two-part process. First, add this to your site to modify the excerpt part with the relevanssi_excerpt_part filter to show the source data: add_filter( ‘relevanssi_excerpt_part’, ‘rlv_excerpt_parts’, 10, 2 ); function rlv_excerpt_parts( $excerpt_text, $excerpt )…

PSA: New ransom scam in town
We were threatened with a new ransom extortion message. I haven’t seen this one before, looks like it’s new but…

Related Posts:

Comment Section:

2 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