php – Show current custom taxonomy

Question

I have a custom post and custom taxonomy my taxonomy is called “department”

i have my loop showing my custom post, I am trying to also show all the departments (custom taxonomy) that my custom post falls under.

My different post are all set different departments however I am only seeing the same department on each post, not the department related to the post.

Am i missing something to show this ?

<ul>
                    <?php
                    $loop = new WP_Query(array('post_type' => 'career', 'posts_per_page' => 10));
                    $taxonomy = get_queried_object();
                    while ($loop->have_posts()) :
                        $loop->the_post(); ?>
                        <li>
                            <p><?php echo $term->name; ?></p>
                            <?php
                            echo 'Department', $taxonomy->name;
                            the_title();
                            $link = get_field('job_link');
                            if ($link):
                                $link_url = $link['url'];
                                $link_title = $link['title'];
                                $link_target = $link['target'] ? $link['target'] : '_self';
                                ?>

                                <a class="button" href="<?php echo esc_url($link_url); ?>"
                                   target="<?php echo esc_attr($link_target); ?>"><?php echo esc_html($link_title); ?></a>
                            <?php endif;
                            ?>
                            <p>Location: <?php the_field('location'); ?></p>
                        </li>
                    <?php endwhile; ?>
                </ul>

0
Beep 4 months 2022-04-13T12:13:12-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse