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

Filtering results by category

…you want to. Remember that whenever you link to search results like that, it’s a good idea to tell Google and other bots to avoid indexing the results. The link above has the “rel=’nofollow’” instruction, but you can also use robots.txt to prevent bots from spidering your search results pages….In order to filter search results by category, use the following code: $url = get_bloginfo(‘url’); $url = esc_attr(add_query_arg(array(‘cat’ => ’10’, ‘s’ => get_search_query()), $url)); echo “Filter by category 10”; Put this in your search results template. What the code does is to create a link that takes the current search……query and adds the category variable to it. This link filters the results by category 10, change the number to correct category ID to make it filter by the category you want to. Remember that whenever you link to search results like that, it’s a good idea to tell Google…

Indexing trashed posts
By default, Relevanssi does not index trashed posts. If you want to enable searching for trashed posts in the WordPress…

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