Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Show image for taxonomy pages in Ajax Search Pro
This topic contains 4 replies, has 2 voices, and was last updated by remkovdz 9 years, 1 month ago.
- AuthorPosts
- March 10, 2015 at 7:39 pm #4147
I’d like the live search results for taxonomies to show an image.
When you search for ‘Slips’ you the result ‘Slips’ returned. This page has a thumbnail set I’d like to be displayed.
March 11, 2015 at 10:45 am #4151Hi!
I can’t seem to log in to the site, it requests .htaccess authentication. Could you please check that, or upload a txt file with authentication details?
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 11, 2015 at 10:47 am #4152.htaccess credentials are in the popup 😉
March 11, 2015 at 11:36 am #4154Thank you 😉
After some debugging I was able to find the storage method of the images. I’ve implemented the following code to your themes functions.php file:
add_filter( "asp_results", "asp_extra_terms_image_results", 1, 1 ); function asp_extra_terms_image_results( $results ) { foreach ($results as $k=>$v) { // get the term images if ($results[$k]->image != null && $results[$k]->image != "") continue; /* Try to get woocommerce image */ $x = get_woocommerce_term_meta( (int)$v->id, 'thumbnail_id', true ); if ($x != "") { $im = wp_get_attachment_url( $x ); if ($im != '') { $bfi_params = array('width' => 70, 'height' => 70, 'crop' => true); $results[$k]->image = bfi_thumb($im, $bfi_params); } } /* Other term image then.. */ $x = get_metadata("woocommerce_term", (int)$v->id); if (isset($x['pa_merk_thumbnail_id_photo'][0])) { $im = wp_get_attachment_url( $x['pa_merk_thumbnail_id_photo'][0] ); if ($im != '') { $bfi_params = array('width' => 70, 'height' => 70, 'crop' => true); $results[$k]->image = bfi_thumb($im, $bfi_params); } } } return $results; }
Since it is placed into the themes functions.php file, this code will remain in case of updating the search plugin.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 11, 2015 at 11:40 am #4155Works great, thanks!
- AuthorPosts
The topic ‘Show image for taxonomy pages in Ajax Search Pro’ is closed to new replies.