Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to display terms image ?
This topic contains 6 replies, has 2 voices, and was last updated by superman 9 years, 4 months ago.
- AuthorPosts
- December 12, 2014 at 2:47 pm #3224
Hi Ernest,
Is it possible to display terms image ? The terms have a field name ‘Big Icon Path’ where is image source. I set custom field containing the image, but it doesn’t work.
https://drive.google.com/file/d/0B4BrGeTR-ESZR09VSHlwTzZVTEU/view?usp=sharingBest
KenDecember 12, 2014 at 2:59 pm #3225Hi!
Taxonomy terms does not have images by default. As I can see it must be a feature of your theme.
It’s definitely not a custom field, only posts/custom post types can have them.However if you can ask the theme developer how to get the term image based on the term id, then I might be able to put something together for you.
There must be a funtion like get_term_image_by_id($term_id) or something similar defined somewhere. Once we have that, it’s going to work.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 15, 2014 at 2:04 am #3231Hi,
I have asked the theme developer.
To theme developer question:How to get the term Big Icon Path image based on the term id ?
The response : Icons are stored in theme options, you should be able to use the code like this $GLOBALS[‘CORE_THEME’][‘category_icon_’.$item->object_id] to show it .Best
KenDecember 15, 2014 at 1:13 pm #3235Hi!
Great! I think this will help. So, based on this article: https://wp-dreams.com/knowledge-base/numbering-the-results/
let me try to put together a similar function. Try to put this code into to your themes functions.php file:add_filter( "asp_results", "asp_term_image_results", 1, 1 ); function asp_term_image_results( $results ) { foreach ($results as $k=>$v) { // get the term images if (isset($GLOBALS["CORE_THEME"]["category_icon_".$results[$k]->id])) $results[$k]->image = $GLOBALS["CORE_THEME"]["category_icon_".$results[$k]->id]; } return $results; }
- This reply was modified 9 years, 4 months ago by Ernest Marcinko. Reason: apostrophes
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 16, 2014 at 3:44 pm #3255Thanks, It work!
But I have another custom taxonomy,it has a custom field name “icon” .I built it via pods plugin.
https://drive.google.com/file/d/0B4BrGeTR-ESZSkRfSFFzeGx2aXc/view?usp=sharingThis is answer How to display taxonomy custom fields.
http://pods.io/forums/topic/displaying-extended-taxonomy-custom-fields/But I don’t understand how to put it together based on this article: https://wp-dreams.com/knowledge-base/numbering-the-results/
December 18, 2014 at 2:04 pm #3275Hi!
I’ve looked at those links. There is something that might work:
add_filter( "asp_results", "asp_pods_image_results", 1, 1 ); function asp_pods_image_results( $results ) { foreach ($results as $k=>$v) { // get the term images if ($results[$k]->image != null && $results[$k]->image != '') continue; $pod = pods('category'); $pod->fetch($category->term_id); $icon = $pod->get_field('icon'); if ($icon != null && $icon != '') $results[$k]->image = $icon; } return $results; }
I cannot test this code, so it might not work. But I guess it’s very close to a solution.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 19, 2014 at 8:10 am #3277Hi,
It doesn’t work. I have open another ticket and provide my FTP information.Best Ken
- AuthorPosts
The topic ‘How to display terms image ?’ is closed to new replies.