Support

Account

Home Forums General Issues Display custom field from category on child single page Reply To: Display custom field from category on child single page

  • Hello John,

    Thank you for your help.
    Indeed, I’m talking about a single post page.

    Do I need to specify that it’s a category from a custom post type ?
    So it’s a taxonomy called “destinations”.

    So I adapt your code like this in my template single-destinations.php, no ? :

    <?php $top_term = $term;
    if ($term->parent) {
      // term has a parent
      $ancestors = get_ancestors($term_id, 'destinations', 'taxonomy'); 
      $top_term_id = array_pop($ancestors);
      $top_term = get_term($top_term_id, 'destinations');
    }
    if(get_field('big_image', $top_term)) { ?>
      <p>Hello !</p>
    <?php } ?>

    Nothing happens… 🙁 Is there something wrong ?