I have inmy opinion something simple that needs to be done but I can't get it to work.

I have a custom post type adm_project with rewrite => array('slug' => 'projecten')

add_action( 'init', 'adm_build_projecten_post_type', 0 );
function adm_build_projecten_post_type() {

            'label' => 'Werkgebieden',
            'singular_label' => 'Werkgebied',
            'hierarchical' => true,
            'query_var' => true,

    $labels = array(
        'name'               => 'Projecten',
        'singular_name'      => 'Project',
        'menu_name'          => 'Projecten',
        'all_items'          => 'Alle Projecten',
        'add_new'            => 'Project toevoegen',
        'add_new_item'       => 'Nieuwe Project',
        'edit'               => 'Bewerken',
        'edit_item'          => 'Project bewerken',
        'new_item'           => 'Nieuwe Project',
        'view'               => 'Bekijken',
        'view_item'          => 'Bekijk Projecten',
        'search_items'       => 'Zoek Project',
        'not_found'          => 'Geen Project(en) gevonden',
        'not_found_in_trash' => 'Geen Project(en) in prullenbak gevonden',
        'parent'             => '',

    $args = array(
        'label'               => 'Projecten',
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 20,
        'menu_icon'           => 'dashicons-hammer',
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page',
        'rewrite'             => array( 'slug' => 'projecten' )

    register_post_type( 'adm_project', $args );


In the theme I have a file name archive-adm_project.php which shows all the projects including working pagination as wanted.

What I want is that when I go to


it does exactly the same but only show projects that have the taxonomy that is in the url.

2 Answers 2


I've not seen a "clean" way to do this - happy to learn it from someone else if they know.

However, the way we've managed this in the past is to setup a page whose slug is 'projecten' with a custom page template that behaves and acts like an archive page. Then add child pages for each term (make sure to select the custom taxonomy for each term child page that relates - well this is only really important depending on how you want to find the term).

This will get you the slug structure you want. You can then use the page template you created to also find the second url parameter (or find the taxonomy that relates to the post) and add a tax_query to the WP Query to limit by taxonomy term. Or try it another way, once you have that parent/child page relationship and your slug structure complete...

I'm sure you can figure out the best way for you to code the required output.

  • I did think about creating child pages for every term but that would mean creating a new template every time a term is added. Never thought about just using the child page slug as the tax_query. I will use this for now as I can't think of a cleaner way either. Thanks!
    – Jebble
    Oct 14, 2015 at 14:02
  • Your welcome - sorry about the multiple edits on this one - thought i had another approach but I need to hit the drawing board again.
    – Spongsta
    Oct 14, 2015 at 14:04
  • That's okay. I'm already glad I got a push in a usefull direction. I was completely stuck on this one as normally I'd use our ready made ajax filter but I couldn't use that this time :)!
    – Jebble
    Oct 14, 2015 at 14:05

1) Create a template called taxonomy-TAXONOMY_NAME.php)

2) add the following WP Query to the template

global $post;
$term = get_the_terms($post->id, 'TAXONOMY_NAME');
$args = array(
 'post_type' => 'POSTTYPE_NAME',
 'tax_query' => array(
   'taxonomy' => 'TAXONOMY_NAME',
   'field'    => 'slug',
   'terms'    => $term,
$query = new WP_Query( $args );

You will need to add the rest of the query stuff (like adding a title, excerpt etc) but that should (not tested) pull in all posts from the term which is defined for the page you are on.

  • Why do you want to run a custom query on a taxonomy template Oct 14, 2015 at 13:08
  • But wouldn't that make the taxonomy archive look like website.com/TAXONOMY instead of website.com/projecten/TAXONOMY ?
    – Jebble
    Oct 14, 2015 at 13:09
  • @PieterGoosen that did look funny to me as well
    – Jebble
    Oct 14, 2015 at 13:12

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.