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.
Related Posts
Related Posts
...Relevanssi uses a simple CSS grid to lay out the related posts. This setting determines the minimum width of each element. Experiment with different values to see what works. If you want to style the related posts, Relevanssi wraps everything inside div#relevanssi_related, the header is in div.relevanssi_related_grid_header, and the grid......itself is in div#relevanssi_related_grid. Each post is a div.relevanssi_related_post. If you want to make more extensive modifications, you can create your template. Relevanssi will look for the relevanssi-related.php template inside the current theme templates directory, and if it finds one, it will use that instead of the default template. When......<li class="relevanssi_related_post"> <a href="<?php echo get_permalink( $related_post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>"> <?php echo get_the_title( $related_post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> </a> </li> <?php } ); ?> </ul> </div> <?php endif; Single post settings There are also Related posts controls on post edit pages. You can disable the auto-append for...
Indexing embedded PDFs for the parent post
...} } return $block; } ); PDF.js Viewer Shortcode PDF.js Viewer Shortcode uses a shortcode with the file name in the url parameter. add_filter( 'relevanssi_content_to_index', 'rlv_pdfjs_content', 10, 2 ); function rlv_pdfjs_content( $content, $post ) { $m = preg_match_all( '/\[pdfjs-viewer url=["\'](.*?)["\']/', $post->post_content, $matches ); if ( $m ) { global $wpdb;......need to establish a connection between the PDF and the post, based on the URL in the shortcode. The same code works with different PDF embedders; you only have to adjust the regex to match the shortcode used by the plugin. WordPress Core File block If you use the default......WordPress. Thus, Relevanssi won’t know the PDF is embedded in the post and cannot index the PDF contents for the parent post. Most of these plugins use shortcodes to embed the PDF viewer on a page. To get Relevanssi to index the embedded PDF contents for the parent post, you...
Installing Relevanssi and adjusting the settings
...words to the search query and in OR search that works as expected, widening the search. In AND search, it will restrict the search, so it won’t work. Enabling this option will make Relevanssi index the synonyms as part of the post content, making them compatible with AND searches. Index......operator OR search will return all posts where at least one of the search terms appears. AND search will only return posts that have all search terms in them. OR search will prefer posts that have all search terms in them, so in most cases it is the better option.......all on all search forms on the site. If a search form includes the searchblogs parameter, it will override this setting. You still need to modify the search results template to get working permalinks, this (and the next) setting is just a shortcut for setting the searchblogs parameter. Search some...
Indexing image captions for the posts
The use case is I run several newspapers, and the “caption” field when uploading media is where the journalists put the photographer credit. We need to be able to index the photographer bylines, but i...
Indexing attachment file names
...( 'attachment' === $post->post_type ) { $content .= ' ' . basename( $post->guid ); } return $content; } Notice that by default Relevanssi replaces periods with spaces, so “sample.pdf” is indexed as “sample pdf”. That should not be a problem, as also in searching “sample.pdf” becomes “sample pdf”. However, if...Relevanssi has been working nicely for the normal usecase. But how does one setup indexing of attachment files. When someone searches by a file name or an extension like pdf, there are no results. I have enabled ‘attachment’ at Relevanssi ‘Indexing options’ and still there are no results. Relevanssi doesn’t...
ACF: Indexing relationship content
...know the exact field name. In that case you can use a direct database call to fetch fields using wild cards. This function would find a relationship field called people inside a flexible content field sidebar_groups: add_filter( 'relevanssi_content_to_index', 'rlv_relationship_content', 10, 2 ); function rlv_relationship_content( $content, $post ) { global $wpdb;...
Does that contains products id also?
Sure, a post ID is a post ID, no matter the post type. They’re all posts to Relevanssi.