• Hi I am having a problem getting the function to work.

    I have a custom post type called ‘bodhitalk’ and that post type has a custom taxonomy called ‘teacher’.

    I am trying to call this function in a custom “single” page (in my case single-bodhitalk.php.)
    So in I put this after ‘<?php while ( have_posts() ) : the_post(); ?>’:

    <?php
    if (function_exists(‘get_wp_term_image’)) {
    $meta_image = get_wp_term_image(teacher);
    }
    ?>

    Then later in my code I call <?php echo $meta_image; ?>

    I tried get_wp_term_image(teacher) and get_wp_term_image(‘teacher’) and get_wp_term_image($teacher), nothing is working.

    Can you help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter semidivine

    (@semidivine)

    Part of the problem seems to be the page is not recognizing the function.

    I tried:

    if (function_exists('get_wp_term_image')) {
    	echo 'x';
    }

    x did not output on the page.

    Plugin Author Aftab Husain

    (@amu02aftab)

    @semidivine

    Sorry for late reply.
    I think you are not passing category ID / term Id in the function.

    
    if (function_exists('get_wp_term_image'))
    {
        $meta_image = get_wp_term_image($term_id); 
        //It will give category/term image url 
    
        echo $meta_image; // category/term image url 
    }
    

    Be sure , you are passing $term_id (Correct category ID / term Id ) in function , for which you have to get the image.

    Hope this will help .

    Thanks;

    • This reply was modified 7 years, 10 months ago by Aftab Husain.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Function not working in ‘single’ page for custom post type’ is closed to new replies.