Skip to main contentSkip to footer

Sometimes it is helpful to have Relevanssi index the taxonomy term descriptions for posts. For example, the term description can be a good place to add alternate search terms for the term. By default, Relevanssi only indexes the term name, so you need extra code to get the term descriptions.

The filter hook relevanssi_content_to_index is the tool for the job. It can be used to add extra content to posts as they are indexed. Add this function to your site (and replace post_tag with the name of the taxonomy you want to use):

add_filter( 'relevanssi_content_to_index', function( $content, $post ) {
	$terms = get_the_terms( $post->ID, 'post_tag' );
	if ( is_array( $terms ) ) {
		foreach ( $terms as $term ) {
			$content .= ' ' . $term->description;
		}
	}
	return $content;
}, 10, 2);

When you rebuild the index, the term descriptions are indexed for all the posts that have that term.

Your account

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

Search

Popular Resources

WP Download Manager

…these issues. When you upload the files to the Relevanssi attachment reading server, Relevanssi uses the get_attached_file() function to get the file name, but that does not work with WP Download Manager. Thus we need to use the relevanssi_get_attached_file filter hook to provide the file name and path for Relevanssi….…add-on adds an advanced search with the [wpdb_archive_filter] shortcode. That search does not use Relevanssi by default, but it can be modified to make use of Relevanssi with this little function you can add to your site: add_filter( ‘wpdm_packages_query_params’, ‘rlv_use_relevanssi’ ); function rlv_use_relevanssi( $params ) { if ( isset( $params[‘s’]…

Toolset Views
Relevanssi works fine with Toolset, thanks to a lot of compatibility code the makers of Toolset have included in it…
Adding direct links to outside pages to search results

…singular name’, ‘textdomain’ ), ‘menu_name’ => _x( ‘Affiliate links’, ‘Admin Menu text‘, ‘textdomain’ ), ‘name_admin_bar’ => _x( ‘Affiliate link’, ‘Add New on Toolbar’, ‘textdomain’ ), ‘add_new’ => __( ‘Add New’, ‘textdomain’ ), ‘add_new_item’ => __( ‘Add New Affiliate link’, ‘textdomain’ ), ‘new_item’ => __( ‘New Affiliate link’, ‘textdomain’ ), ‘edit_item’……=> __( ‘Edit Affiliate link’, ‘textdomain’ ), ‘view_item’ => __( ‘View Affiliate link’, ‘textdomain’ ), ‘all_items’ => __( ‘All Affiliate links’, ‘textdomain’ ), ‘search_items’ => __( ‘Search Affiliate links’, ‘textdomain’ ), ‘parent_item_colon’ => __( ‘Parent Affiliate links:’, ‘textdomain’ ), ‘not_found’ => __( ‘No Affiliate links found.’, ‘textdomain’ ), ‘not_found_in_trash’ =>……__( ‘No Affiliate links found in Trash.’, ‘textdomain’ ), ‘archives’ => _x( ‘Affiliate link archives’, ‘The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4’, ‘textdomain’ ), ‘filter_items_list’ => _x( ‘Filter Affiliate links list’, ‘Screen reader text for the filter links heading on the post…

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