WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Displaying Custom Field value of a Term from Custom Taxonomy (2 posts)

  1. markyeoj
    Member
    Posted 1 year ago #

    Here is my code

    <?php if (is_tax()) { ?>
    <h1 class="archive_title h2">
    <?php single_cat_title(); ?> Overview
    <span><?php the_field('sub_heading')?></span>
    </h1>
    <?php echo the_field( 'sub_heading'); ?>
    <div class="category-desc">
    <?php echo category_description( get_category_by_slug( 'category-slug')->term_id ); ?></div>
    <?php } ?>

    My Custom field sub_heading, I am trying to display the value but unfortunately not working,

    Here is the archive page where I am using code.

    Thanks

    http://wordpress.org/plugins/advanced-custom-fields/

  2. markyeoj
    Member
    Posted 1 year ago #

    Thank you for the quick response, I already solved my problem..

    <?php
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;
    $subheading = get_field('sub_heading', $taxonomy . '_' . $term_id);?>
    
    <span class="sub_heading"><?php echo $subheading; ?></span>

    Thanks,

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic