Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to display terms image ?
- This topic has 6 replies, 2 voices, and was last updated 11 years, 5 months ago by
superman.
-
AuthorPosts
-
December 12, 2014 at 2:47 pm #3224
superman
ParticipantHi 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 #3225Ernest Marcinko
KeymasterHi!
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.
December 15, 2014 at 2:04 am #3231superman
ParticipantHi,
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 #3235Ernest Marcinko
KeymasterHi!
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:
[php]
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;
}
[/php]-
This reply was modified 11 years, 5 months ago by
Ernest Marcinko. Reason: apostrophes
December 16, 2014 at 3:44 pm #3255superman
ParticipantThanks, 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 #3275Ernest Marcinko
KeymasterHi!
I’ve looked at those links. There is something that might work:
[php]
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;
}
[/php]I cannot test this code, so it might not work. But I guess it’s very close to a solution.
December 19, 2014 at 8:10 am #3277superman
ParticipantHi,
It doesn’t work. I have open another ticket and provide my FTP information.Best Ken
-
This reply was modified 11 years, 5 months ago by
-
AuthorPosts
- The topic ‘How to display terms image ?’ is closed to new replies.