WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made a custom post type called "Case Studies".

There is a case studies page which displays the title of every custom post and a small exceprt. However when you click on the title to view the single post, on the navigation the current tab changes from "Case studies" to "News". Where news is the default post page and case studies is a templated page.

Is there a way to make the custom post type a child of the Case Studies page? Or atleast set a template file that I can use for the custom post type. When you view a single case study post I need the navigation to show that you are still on the Case Studies page and not on News.


share|improve this question
how are the tabs activated at the moment? Using CSS? have you used firebug to see if you can tweak the rule to make it work for you? – Mild Fuzz Sep 21 '10 at 9:34
it uses wordpress's .current-page class.I cant use jquery to remove class and add the class to the right menu item because I need full no-javascript compatability. ): – adamtomat Sep 21 '10 at 10:32
Can you add the code from the menu for case studies and the single custom post type? – Chris_O Sep 22 '10 at 2:50
// Template redirect for custom templates
add_action( 'template_redirect', 'template_redirect' );

public function template_redirect() {
    global $wp_query;
    if ( $wp_query->query_vars['post_type'] == 'case_studies' ) {
        get_template_part( 'single-casestudies' ); // a custom page-slug.php template

This is the same thing that @Dalton mentioned, you would want to create a custom page template named page-casestudies.php or whatever you want to name it, then make a page in WP admin that has a slug of 'casestudies' to match the page-{slug}.php or page-{id}.php where the page id matches. And you can use the page.php code, with a line or two before the if(have_posts() while(have_posts() Loop. Sort of like this:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => 'case_studies', 'paged' => $paged ));

if (have_posts()) : while (have_posts()) : the_post();

Sorry if I misunderstood the problem, but I think this would fix it.

share|improve this answer

I believe you want to use the rewrite parameter to change the permalink to your custom post type. As far as creating a custom post template, the format is single-CUSTOMPOSTTYPE.php

Here's the reference I found for this: http://kovshenin.com/archives/extending-custom-post-types-in-wordpress-3-0/

For example, on my site I have a normal page called "Animation" which is a landing page for my custom post type (animations). My rewrite slug is 'animation' and my template is single-animation.php. The permalink structure looks like mysite.com/animation/name-of-animation

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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