Support » Themes and Templates » Custom Post Type Slug vs Page Slug

  • Hello,

    This is my first post here on the WordPress forums. Luckily I have been able to get by using the codex and forum search. I am just learning wordpress as I create themes and troubleshoot them along the way.


    I have recently started dabbling in custom post types.
    I have a custom post type called “Portfolio”
    Currently each post displays perfectly with the permalink structure as

    I also have a page that displays my portfolio entries (which I did by creating a page and applying the page-portfolio.php template to it)
    Currently it is set at

    What I want is my portfolio page to show up as
    and each entry to go to

    If i do this now, it creates problems and my page-portfolio.php template doesnt show up. I am thinking it has to do with slugs and rewrites which is why I changed it to portfolio-home to get around it. However, I don’t like the way that looks.

    Any ideas?

    if it helps, I used this tutorial to create my custom post type:

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can’t really do what you are trying to do in the way you would like to do it.

    /portfolio/ is registered with the custom post type as the custom post type permalink associated with that custom post type.

    when you give a page the same permalink that is associated with the custom post type permalink, you create a conflict. WordPress knows how to display pages based on the requested URL and what are called the rewrite rules. This is a sequential list of all the possible rules of URL’s that your site can display. It goes down the list one by one looking for a rule that matches. Custom Post Type rules are ahead of page rules in the sequence. So when WordPress sees
    it knows that as the custom post type archive page, and that is what its going to display. It doesn’t even reach the part of its rules that are aware of as a page because it has already taken action on the first match it found, which is the custom post type archive page.
    You have a URL clash – two types of content trying to display at the same URL. That won’t work.


    Well it was worth a shot checking the forums. Thanks for the input on the subject. I really appreciate it.


    I solved this conflict by adding an “archive-<post_type>.php” template, grabbing the page directly and starting a new loop. In this case, here would be the contents of “archive-portfolio.php”

    query_posts( ‘post_type=page&name=portfolio’ );
    // The Loop
    if ( have_posts() ) : the_post();
    include( ‘template-portfolio.php’ );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Type Slug vs Page Slug’ is closed to new replies.