Skip to main contentSkip to footer

Relevanssi doesn’t by default index the headings in Visual Composer. The vcex_heading shortcode Visual Composer for the headings stores the heading text inside a shortcode attribute. By default, Relevanssi does not index shortcode attributes.

In this case, indexing the shortcode attribute is necessary. Fortunately, it’s easy to fix with a simple function added to your site:

add_filter( 'relevanssi_pre_excerpt_content', 'rlv_shortcode_attribute', 8 );
add_filter( 'relevanssi_post_content', 'rlv_shortcode_attribute', 8 );

function rlv_shortcode_attribute( $content ) {
	return preg_replace( '/\[vcex_heading.*?text="(.*?)".*?\]/im', '\1 ', $content );
}

After you add this function, rebuild the index. Now the headings are included in the index. This function is added to two hooks: relevanssi_pre_excerpt_content handles the excerpts and relevanssi_post_content the indexing.

Your account

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

Search

Popular Resources

Issues with post order plugins

…then you may be using a plugin that affects the post order. One example is Intuitive Custom Post Order, which reorders posts – and the Relevanssi results. The fix is simple, though. Add this function to your site: add_filter( ‘relevanssi_orderby’, function ( $orderby ) { return array( ‘relevance’ => ‘desc’ );…

Total
Total is a popular theme from WPExplorer. It mostly works fine with Relevanssi, with just one little issue. Total sets…
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…

Related Posts:

Comment Section:

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