How to display terms image ?

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

 
Participant
7 years, 1 month ago.

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

    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 7 years, 1 month ago by  superman.
    • This topic was modified 7 years, 1 month ago by  superman.
    #3225

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #3231

    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

    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:

    
    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 7 years, 1 month ago by  Ernest Marcinko. Reason: apostrophes
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #3255

    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

    Hi!

    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 :)


    #3277

    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.