Support

Account

Home Forums General Issues display my taxonomy's image and text fields on taxonomy term page

Solved

display my taxonomy's image and text fields on taxonomy term page

  • Hello, I have a taxonomy called Magazine, attached to my normal posts. I have added a few fields to the taxonomy, an image and a description (WYSIWYG field). The custom slug is “editions”.

    On http://mysite.com/editions/damn-50/, I have all the posts attached to this taxonomy loading, but above that, I want to display the taxonomy image and description. I have followed instructions here: http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/, but no luck.

    Here is a screenshot of how I setup the ACF fields (image is an ID)
    http://mikelythcott.com/ACF-setup.png

    And my taxonomy edit screen
    http://mikelythcott.com/taxonomy.png

    Here is how I would like to display the image and description

    <article <?php post_class(”); ?>>
    <div class=”entry-content”>
    <div class=”row”>
    <div class=”col-xs-12 col-sm-6 col-md-5″>
    <div class=”post-image”>

    <?php $magazineimage = wp_get_attachment_image_src(get_field(‘magazine_taxonomy_image’, ‘magazine_9049’), ‘full’); ?>
    <?php echo $magazineimage[0]; ?>

    </div>
    </div>
    <div class=”col-xs-12 col-sm-6 col-md-7″>
    <?php the_field(‘magazine_taxonomy_description’, ‘magazine_9049’); ?>
    </div>
    </div>
    </div>
    </article>

  • Hi @michaellawrence

    Please post code within code tags as it makes it so much easier to look at as well as copy etc.

    Could you try this:

    
    <?php $term = $wp_query->queried_object; ?>
    <?php the_field('magazine_taxonomy_description', $term->taxonomy . '_' . $term->term_id); ?>
    
  • Worked like a charm, thanks a lot!

    here is my code for other people, with the same question, to reference

    <?php $term = $wp_query->queried_object; ?>
    
    <article <?php post_class(''); ?>>
      <div class="entry-content">
        <div class="row">
          <div class="col-xs-12 col-sm-6 col-md-4">
            <div class="post-image">
    
              <?php $magazineimage = wp_get_attachment_image_src(get_field('magazine_taxonomy_image', $term->taxonomy . '_' . $term->term_id), 'full'); ?>
              <img src="<?php echo $magazineimage[0]; ?>" alt="<?php echo get_the_title(get_field('magazine_taxonomy_image')) ?>" class="placeholder" />
    
            </div>
          </div>
    
          <div class="col-xs-12 col-sm-6 col-md-8">
            <?php the_field('magazine_taxonomy_description', $term->taxonomy . '_' . $term->term_id); ?>
          </div>
        </div>
      </div>
    </article>
  • Hi @michaellawrence

    Great 🙂 Would you please mark an answer so this topic is closed properly.

    If you need help with ACF again don’t hesitate to post a new topic in the forums and we’ll try to help you out.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘display my taxonomy's image and text fields on taxonomy term page’ is closed to new replies.