Support

Account

Home Forums Front-end Issues Display taxonomy value

Helping

Display taxonomy value

  • I’m having trouble getting my taxonomy values to show up. I have custom post type = staff, with custom taxonomy = department. Set up custom field with taxonomy field type, selected “Departments” in drop down. Field type is checkbox, load & save is checked, return value = term id.

    code from single-staff.php:

    <?php while ( have_posts() ) : the_post(); ?>
                    
                    <?php
     
    					global $post;
    					 
    					// load all 'category' terms for the post
    					$terms = get_the_terms($post->ID, 'department');
    					 
    					// we will use the first term to load ACF data from
    					if( !empty($terms) )
    					{
    						$term = array_pop($terms);
    					 
    						$custom_field = get_field('department', 'department_' . $term->term_id );
    					 
    						// do something with $custom_field
    					}
    					 
    				?>
                        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                            <div class="entry-content">
                                
                                    <img src="<?php the_field('photo'); ?>" class="staff-photo" />
                                    <h4 class="staff-job-title"><?php the_field('job_title'); ?></h4>
                                    <h4 class="staff-department"><?php echo $custom_field; ?></h4>
                                    <h4 class="staff-email"><?php the_field('email_address'); ?></h4>
                                    <h4 class="staff-phone"><?php the_field('phone_number'); ?></h4>
                                   
    
                                    <p class="staff-bio"><?php the_field('bio'); ?></p>
                                   
                            </div>
                         </article>
    
    				<?php endwhile; ?>

    I’ve tried everything on: http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

    also, I have no metabox selected but it is still showing up in sidebar of edit post.

    thanks for any help

    • Elliot

    • August 16, 2013 at 2:41 pm

    Hi @designsolu

    I’m not exactly sure what is and isn’t working for you.

    Have you attempted to debug the issue? As in, print out the variables to see where the code works and where it doesn’t?

    Cheers
    E

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.