Home Forums Front-end Issues Display taxonomy value


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(); ?>
    					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>
    				<?php endwhile; ?>

    I’ve tried everything on:

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

    thanks for any help

  • 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?


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

The topic ‘Display taxonomy value’ is closed to new replies.