Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » 404 page when accessing CPT-onomy post

  • Hi All,

    I’ve been trying to get this to work but havent made any success.
    The issue is as follows:
    I maded a CPT in the backend ‘showcase’ and added posts to the CPT. When i tried to view the post initially i got a 404 page.
    So I added a rewrite rule:

    function add_showcase_rules() {
     global $wp_rewrite;
    add_action( 'init', 'add_showcase_rules' );

    and set the permalink to ‘’
    and added a template include function:

    function tax_page_template( $template ) {
      global $post_type;
      if ( $post_type == 'showcase' || $post_type == 'work' ) {
          if ( $custom_template = locate_template( "single-$post_type.php" ) )
             return $custom_template;
       return $template;

    Now when i go to this page:
    I see the proper page, but i dont have proper URL handling

    With proper URL handling, i see ALL the posts related post_type ‘showcase’ >

    The question:
    How can i get AND proper URL handling AND only the relevant post?

    Thanks in advance : )

Viewing 1 replies (of 1 total)
  • Ok in the meantime i have done some diggin around my self. I ended up going thru the class-wp.php file (WP::parse_request). I came up with the following rewrite rule which works with my CPT.

    function add_cpt_rules() {
      global $wp_rewrite;
        "index.php?showcase=" . $wp_rewrite->preg_index(1) . "&page=" . $wp_rewrite->preg_index(2),
        "index.php?work=" . $wp_rewrite->preg_index(1) . "&page=" . $wp_rewrite->preg_index(2),
    add_action( 'init', 'add_cpt_rules' );

    showcase and work are my additional CPTs i removed the extra template include function. As WP now grabs the post_type for the relevant template file.

    Using Debug This plugin helped a lot. (



Viewing 1 replies (of 1 total)
  • The topic ‘404 page when accessing CPT-onomy post’ is closed to new replies.