This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: No pictures from Envira gallery when matching caption text

Home Forums Product Support Forums Ajax Search Pro for WordPress Support No pictures from Envira gallery when matching caption text Reply To: No pictures from Envira gallery when matching caption text

#31497
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Thank you for the deteils. The reason it didn’t work, because there is no featured image, nor any content within those gallery posts whatsoever, so the plugin was not able to get any images from that.

Luckily I found some information on their documentation API, and added the following code to your theme functions.php file to parse the images during a post process:

add_filter( 'asp_results', 'asp_envira_images', 10, 1 );
function asp_envira_images( $results ) {
	foreach ($results as $k=>&$r) {
		if ( isset($r->post_type) && $r->post_type == 'envira' ) {
			$r->image = asp_get_image_from_content( do_shortcode('[envira-gallery id="'.$r->id.'"]') );
		}
	}

	return $results;
}

Please keep that code in there.

Also note, that we cannot guarantee that this solution works a 100% of the time, as it qualifies as a custom coding request. Personally I think it should be perfectly fine though.