Skip to main contentSkip to footer

Gmedia photo gallery gives a false impression of working with Relevanssi, as you can see the gmedia_tag taxonomy appear in the list of taxonomies:

Gmedia tags
gmedia_tag is listed in the list of taxonomies to index.

However, if you try to index those tags, you’ll soon notice Relevanssi isn’t actually indexing them. That’s because Gmedia gallery doesn’t use that taxonomy for the tags. The tags are actually in a separate, proprietary taxonomy Relevanssi won’t have access at all.

There is a solution, though. When indexing gallery photos, you can add a function that reads in the actual Gmedia tags, and adds them to the post content before it is indexed by Relevanssi. The code looks something like this:

add_filter( 'relevanssi_content_to_index', 'rlv_index_gmedia_tags', 10, 2 );
function rlv_index_gmedia_tags( $content, $post ) {
	if ( 'gmedia' === $post->post_type ) {
		$id = get_post_meta( $post->ID, '_gmedia_ID', true );
		if ( ! empty( $id ) ) {
			global $gmDB;
			$tags = $gmDB->get_the_gmedia_terms( $id, 'gmedia_tag' );
			if ( is_array( $tags ) ) {
				foreach ( $tags as $tag ) {
					$content .= $tag->name;
				}
			}
		}
	}
	return $content;
}

This checks the post type: if it’s gmedia, the photo ID in the Gmedia database is fetched from the _gmedia_ID custom field. That ID is then used to fetch the terms with $gmDB->get_the_gmedia_terms( $id, 'gmedia_tag' );. The terms are then looped through and the term name is added to the post content, where it will be indexed.

There’s lots of subtle finesses that are missing – this code will for example make your site crash if Gmedia is disabled at some point, but it should get you started with adding better support for Gmedia photo galleries.

Your account

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

Search

Popular Resources

GDPR Compliance

…except when you index attachment content. That Relevanssi can’t do on your own server. In order to index attachment content, the attachment is sent to a Relevanssi indexing server. These servers are hosted by UpCloud (their privacy policy) and are in the US or in EU. You can choose which……doesn’t share any information outside your own server. There are, however, two exceptions. Logging If you enable logging, Relevanssi will log all search queries, except from those users you block in the settings. The logs will always include the user ID and if you so desire, the user IP address….…completely from the system, that will automatically remove all log entries with their user ID. Relevanssi can’t automatically remove log entries for searches users do when they are not logged in, as Relevanssi cannot connect IP address to user ID. Attachment indexing Relevanssi doesn’t share any information outside your server,…

Yoast Local SEO
Yoast Local SEO plugin breaks Relevanssi search. It enhances the search by adding meta queries. Unfortunately they don’t work with…
OceanWP
OceanWP is a popular WordPress theme. It works fine with Relevanssi, but how it handles excerpts on the search results…

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