I have two custom post types - office and professional. Each professional needs to be tied to an office. I've created a custom taxonomy, 'tax-location', applied it to both post types to tie them together.

I can view each single view of the ctp for office and professional with the templates single-office.php and single-professional.php as expected.

What I now need is to create a page that lists professionals by office on it's own page (think a subpage of the single-office view) and how to get that permalink dynamically. I've tried the taxonomy-$taxonomy-$slug.php template, but can't see to get it to work.

==== My Solution======

I ended up revisiting the taxonomy template solution. My taxonomy slug is tax-location, so I made a taxonomy-tax-location.php template.

To get the term link, I used the get_term_link() and passed the object through the first parameter, which echoes my link to a select field.

$career_terms = get_terms( 'tax-location' );
foreach ( $career_terms as $career_term ) {
    $term_link = get_term_link( $career_term, 'tax-location')
    echo '<option value="' . $term_link . '">' . $career_term->name . '</option>';

From here I used javascript to bounce the user to the selected link that will take them to the taxonomy-tax-location.php template.

Once on the taxonomy-tax-location.php page, I wrote a function that passes the term slug of the queried page to a new WP_Query.

// in taxonomy-tax-location.php 
$term = $wp_query->queried_object;

// in functions.php
function kg_get_careers($term_slug = '') {

    $career_args = array(
        'post_type' => 'career',
        'posts_per_page' => -1,
        'tax-location' => $term_slug

    $career_posts = new WP_Query( $career_args );

    if ( $career_posts->have_posts() ) :
        while ( $career_posts->have_posts() ) : $career_posts->the_post();
            get_template_part( 'library/partials/part', 'careers-list' );


    echo 'No Content';



My solution is a bit verbose and I'm sure there's room for improvement, but it works for now.

  • So you need a template that applies to the "professional" custom post type but organizes all of them by office on one page? Or is it that you need a template that covers both "professional" as a custom post type but one page per "office"?
    – RachieVee
    Nov 26, 2014 at 19:15
  • I need a template that lists all the professionals of an office. So if I click on the austin office, I want the user to be taken to page that lists the professionals for just that office. Nov 26, 2014 at 20:00
  • Can you tell us what happens when you try the taxonomy-$taxonomy-$slug.php? I have a feeling you may need to edit a template directly. In the meantime, this might help: codex.wordpress.org/…
    – RachieVee
    Nov 26, 2014 at 20:37

1 Answer 1


You can use the plug-in CPT-onomies. It gives you the ability to set cpt office as a taxonomy for professionals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.