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

How to display terms image ?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How to display terms image ?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #3224
    supermansuperman
    Participant

    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=sharing

    Best
    Ken

    • This topic was modified 11 years, 5 months ago by supermansuperman.
    • This topic was modified 11 years, 5 months ago by supermansuperman.
    #3225
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    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.

    #3231
    supermansuperman
    Participant

    Hi,
    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
    Ken

    #3235
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    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 MarcinkoErnest Marcinko. Reason: apostrophes
    #3255
    supermansuperman
    Participant

    Thanks, 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=sharing

    This 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/

    #3275
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    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.

    #3277
    supermansuperman
    Participant

    Hi,
    It doesn’t work. I have open another ticket and provide my FTP information.

    Best Ken

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘How to display terms image ?’ is closed to new replies.