mgsisk / webcomic

Comic publishing power for the web. Turn your WordPress-powered site into a comic publishing platform with Webcomic.
http://wordpress.org/plugins/webcomic
GNU General Public License v2.0
110 stars 29 forks source link

Webcomic Install Causes CPT 404s #147

Closed tnog closed 10 years ago

tnog commented 11 years ago

I installed the plugin to test it on a development site for a project where I need to add webcomic functionality. However, on activation it seems that the plugin is overriding my existing CPT links to both the post/taxonomy archive and single pages.

I tried all of the existing solutions: visited and saved permalinks page, added flush_rewrite_rules, etc. But nothing seems to work. If I deactivate the plugin, the CPT archive and single post links work as they should.

I've included the relevant parts of my plugin code below that creates the custom post type/ taxonomy and routes the archive and single post queries to use the correct template.


add_action( 'init', 'create_work_taxonomies', 0 );

function create_work_taxonomies() {
    register_taxonomy(
        'tn_cstm_work_taxonomy',
        'tn_cstm_portfolio',
        array(
            'labels' => array(
                'name' => 'Work Categories',
                'add_new_item' => 'Add New Work Category',
                'new_item_name' => "New Work Category"
            ),
            'show_ui' => true,
            'show_in_nav_menus' => true,
            'show_admin_column' => true, //Show custom taxonomy in admin columns
            'show_tagcloud' => false,
            'hierarchical' => true,
            'args' => array( 'orderby' => 'term_order' ),
            'rewrite' => array('slug' => 'portfolio-categories', 'with_front' => false )
        )
    );
}

add_action( 'init', 'create_portfolio_work' );

function create_portfolio_work() {
    register_post_type( 'tn_cstm_portfolio',
        array(
            'labels' => array(
                'name' => 'Portfolio',
                'singular_name' => 'Portfolio Work',
                'add_new' => 'Add New Work',
                'add_new_item' => 'Add New Work',
                'edit' => 'Edit Work',
                'edit_item' => 'Edit Work',
                'new_item' => 'New Work',
                'view' => 'View Work',
                'view_item' => 'View Work',
                'search_items' => 'Search Portfolio Works',
                'not_found' => 'No Works found',
                'not_found_in_trash' => 'No Works found in Trash',
                'parent' => 'Parent Work'
            ),

            'public' => true,
            'show_in_menu' => true,
            'menu_position' => 17.5,
            'taxonomies' => array( '' ),
            'menu_icon' => plugins_url( 'images/portfolio-icon.png', __FILE__ ),
            'rewrite' => array( 'slug' => 'portfolio-work', 'with_front' => false ),  
            'has_archive' => true,
            'supports' => array( 'title', 'page-attributes' )
        )
    );
}

add_action( 'init', 'work_thumbnail_sizes' );

function work_thumbnail_sizes() {
add_image_size( 'work-thumb', 300, 270, true ); // Hard Crop Mode
}

add_filter( 'template_include', 'include_template_function', 1 );

/* Template Display */

function include_template_function( $template_path ) {
    if ( get_post_type() == 'tn_cstm_portfolio' ) {
        if ( is_single() ) {
            // checks if the file exists in the theme first,
            // otherwise serve the file from the plugin
            if ( $theme_file = locate_template( array ( 'single-cstmdisp_portfolio.php' ) ) ) {
                $template_path = $theme_file;
            } else {
                $template_path = plugin_dir_path( __FILE__ ) . 'templates/single-cstmdisp_portfolio.php';
            }
        }
        // Checks if custom post archive then applies template
        elseif ( is_post_type_archive( 'tn_cstm_portfolio' ) ) {
            // otherwise serve the file from the plugin
            if ( $theme_file = locate_template( array ( 'archive-cstmdisp_portfolio.php' ) ) ) {
                $template_path = $theme_file;
            } else {
                $template_path = plugin_dir_path( __FILE__ ) . 'templates/archive-cstmdisp_portfolio.php';
            }
        }

  }
    return $template_path;
}

I haven't found any similar issues from googling and was wondering if the issue is with how I've created my CPTs or if this is a specific bug?

mgsisk commented 11 years ago

Nothing's jumping out at me from your code… but I'm also not sure what Webcomic could be doing to break things. 404's make me think it's a permalink issue, but it sounds like you've tried what you can (and the slugs you have here shouldn't conflict with any of Webcomic's defaults). A few things you might try:

  1. Comment out Webcomic's own `template_include
mgsisk commented 11 years ago

Nothing's jumping out at me from your code… but I'm also not sure what Webcomic could be doing to break things. 404's make me think it's a permalink issue, but it sounds like you've tried what you can (and the slugs you have here shouldn't conflict with any of Webcomic's defaults). A couple of things you might try:

  1. Comment out Webcomic's own template_include function (line 147 in webcomic.php). It shouldn't be causing 404's, but… maybe?
  2. Install Rewrite Rules Inspector. With both your plugin and Webcomic active, RRI should be able to show you if there are, in fact, permalink conflicts between the two that the code isn't showing us.
tnog commented 11 years ago

Thank you Michael. I did follow your advice and it appears that suggestion 1 worked! Of course this isn't really a good solution, since any local changes I make to the plugin code will be overwritten.

Though now I'm left wondering why the template_include is breaking permalinks on my site? Before this I tried a few things including wrapping my plugin functions in a class, which I didn't think would really do anything to solve this problem.

mgsisk commented 11 years ago

That is really strange, but it at least gives me a place to start. I'll see if I can figure out why Webcomic's template_include function is messing with your stuff…

tnog commented 11 years ago

I do appreciate your quick response on this matter. In the meantime, I'll also see if I can figure out why this is causing issues with my permalinks. I'll let you know if I find out anything; would really like to use your plugin rather than having to come up with something from scratch.

Best,

Tak

tnog commented 11 years ago

Also please let me know if you would like me to send you any more info; including the corresponding plugin files. I haven't uploaded the most recent changes to my remote development server, but could do that and also give you access to the sandbox site.

tnog commented 11 years ago

Just an update. I did two things:

  1. I used soulseekah's permalink debug code to dump the state of a query for the custom post type archive and single pages for the custom post type.

This is what I found when line 147 in webcomic.php isn't commented out. Forgive the long spew of debug script:

rewrite rules

array (
  'shop/?$' => 'index.php?post_type=product',
  'shop/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=product&feed=$matches[1]',
  'shop/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=product&feed=$matches[1]',
  'shop/page/([0-9]{1,})/?$' => 'index.php?post_type=product&paged=$matches[1]',
  'webcomic/overboard/?$' => 'index.php?post_type=webcomic1',
  'webcomic/overboard/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=webcomic1&feed=$matches[1]',
  'webcomic/overboard/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=webcomic1&feed=$matches[1]',
  'webcomic/overboard/page/([0-9]{1,})/?$' => 'index.php?post_type=webcomic1&paged=$matches[1]',
  'portfolio/?$' => 'index.php?post_type=tn_cstm_portfolio',
  'portfolio/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=tn_cstm_portfolio&feed=$matches[1]',
  'portfolio/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=tn_cstm_portfolio&feed=$matches[1]',
  'portfolio/page/([0-9]{1,})/?$' => 'index.php?post_type=tn_cstm_portfolio&paged=$matches[1]',
  'ramblings/category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
  'ramblings/category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
  'ramblings/category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
  'ramblings/category/(.+?)/wc-api(/(.*))?/?$' => 'index.php?category_name=$matches[1]&wc-api=$matches[3]',
  'ramblings/category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
  'ramblings/tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
  'ramblings/tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
  'ramblings/tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
  'ramblings/tag/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?tag=$matches[1]&wc-api=$matches[3]',
  'ramblings/tag/([^/]+)/?$' => 'index.php?tag=$matches[1]',
  'ramblings/type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]',
  'ramblings/type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]',
  'ramblings/type/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?post_format=$matches[1]&paged=$matches[2]',
  'ramblings/type/([^/]+)/?$' => 'index.php?post_format=$matches[1]',
  'product-category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_cat=$matches[1]&feed=$matches[2]',
  'product-category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_cat=$matches[1]&feed=$matches[2]',
  'product-category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&paged=$matches[2]',
  'product-category/(.+?)/?$' => 'index.php?product_cat=$matches[1]',
  'product-tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_tag=$matches[1]&feed=$matches[2]',
  'product-tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_tag=$matches[1]&feed=$matches[2]',
  'product-tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?product_tag=$matches[1]&paged=$matches[2]',
  'product-tag/([^/]+)/?$' => 'index.php?product_tag=$matches[1]',
  'buy-stuff/.+?/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'buy-stuff/.+?/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'buy-stuff/.+?/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'buy-stuff/.+?/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'buy-stuff/.+?/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'buy-stuff/(.+?)/([^/]+)/trackback/?$' => 'index.php?product_cat=$matches[1]&product=$matches[2]&tb=1',
  'buy-stuff/(.+?)/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_cat=$matches[1]&product=$matches[2]&feed=$matches[3]',
  'buy-stuff/(.+?)/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_cat=$matches[1]&product=$matches[2]&feed=$matches[3]',
  'buy-stuff/(.+?)/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&product=$matches[2]&paged=$matches[3]',
  'buy-stuff/(.+?)/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&product=$matches[2]&cpage=$matches[3]',
  'buy-stuff/(.+?)/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?product_cat=$matches[1]&product=$matches[2]&wc-api=$matches[4]',
  'buy-stuff/.+?/[^/]+/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'buy-stuff/.+?/[^/]+/attachment/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'buy-stuff/(.+?)/([^/]+)(/[0-9]+)?/?$' => 'index.php?product_cat=$matches[1]&product=$matches[2]&page=$matches[3]',
  'buy-stuff/.+?/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'buy-stuff/.+?/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'buy-stuff/.+?/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'buy-stuff/.+?/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'buy-stuff/.+?/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'buy-stuff/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_cat=$matches[1]&feed=$matches[2]',
  'buy-stuff/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?product_cat=$matches[1]&feed=$matches[2]',
  'buy-stuff/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&paged=$matches[2]',
  'buy-stuff/(.+?)/comment-page-([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&cpage=$matches[2]',
  'buy-stuff/(.+?)/wc-api(/(.*))?/?$' => 'index.php?product_cat=$matches[1]&wc-api=$matches[3]',
  'buy-stuff/(.+?)/?$' => 'index.php?product_cat=$matches[1]',
  'portfolio-categories/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tn_cstm_work_taxonomy=$matches[1]&feed=$matches[2]',
  'portfolio-categories/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tn_cstm_work_taxonomy=$matches[1]&feed=$matches[2]',
  'portfolio-categories/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?tn_cstm_work_taxonomy=$matches[1]&paged=$matches[2]',
  'portfolio-categories/([^/]+)/?$' => 'index.php?tn_cstm_work_taxonomy=$matches[1]',
  'webcomic/overboard/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'webcomic/overboard/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'webcomic/overboard/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'webcomic/overboard/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'webcomic/overboard/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'webcomic/overboard/([^/]+)/trackback/?$' => 'index.php?webcomic1=$matches[1]&tb=1',
  'webcomic/overboard/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic1=$matches[1]&feed=$matches[2]',
  'webcomic/overboard/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic1=$matches[1]&feed=$matches[2]',
  'webcomic/overboard/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?webcomic1=$matches[1]&paged=$matches[2]',
  'webcomic/overboard/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?webcomic1=$matches[1]&cpage=$matches[2]',
  'webcomic/overboard/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?webcomic1=$matches[1]&wc-api=$matches[3]',
  'webcomic/overboard/([^/]+)/prints(/(.*))?/?$' => 'index.php?webcomic1=$matches[1]&prints=$matches[3]',
  'webcomic/overboard/([^/]+)/transcripts(/(.*))?/?$' => 'index.php?webcomic1=$matches[1]&transcripts=$matches[3]',
  'webcomic/overboard/[^/]+/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'webcomic/overboard/[^/]+/attachment/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'webcomic/overboard/([^/]+)(/[0-9]+)?/?$' => 'index.php?webcomic1=$matches[1]&page=$matches[2]',
  'webcomic/overboard/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'webcomic/overboard/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'webcomic/overboard/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'webcomic/overboard/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'webcomic/overboard/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'webcomic/overboard-storyline/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic1_storyline=$matches[1]&feed=$matches[2]',
  'webcomic/overboard-storyline/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic1_storyline=$matches[1]&feed=$matches[2]',
  'webcomic/overboard-storyline/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?webcomic1_storyline=$matches[1]&paged=$matches[2]',
  'webcomic/overboard-storyline/(.+?)/crossover(/(.*))?/?$' => 'index.php?webcomic1_storyline=$matches[1]&crossover=$matches[3]',
  'webcomic/overboard-storyline/(.+?)/?$' => 'index.php?webcomic1_storyline=$matches[1]',
  'webcomic/overboard-character/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic1_character=$matches[1]&feed=$matches[2]',
  'webcomic/overboard-character/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic1_character=$matches[1]&feed=$matches[2]',
  'webcomic/overboard-character/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?webcomic1_character=$matches[1]&paged=$matches[2]',
  'webcomic/overboard-character/([^/]+)/crossover(/(.*))?/?$' => 'index.php?webcomic1_character=$matches[1]&crossover=$matches[3]',
  'webcomic/overboard-character/([^/]+)/?$' => 'index.php?webcomic1_character=$matches[1]',
  'ramblings/webcomic_transcript/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'ramblings/webcomic_transcript/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'ramblings/webcomic_transcript/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/webcomic_transcript/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/webcomic_transcript/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'ramblings/webcomic_transcript/([^/]+)/trackback/?$' => 'index.php?webcomic_transcript=$matches[1]&tb=1',
  'ramblings/webcomic_transcript/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic_transcript=$matches[1]&feed=$matches[2]',
  'ramblings/webcomic_transcript/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?webcomic_transcript=$matches[1]&feed=$matches[2]',
  'ramblings/webcomic_transcript/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?webcomic_transcript=$matches[1]&paged=$matches[2]',
  'ramblings/webcomic_transcript/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?webcomic_transcript=$matches[1]&cpage=$matches[2]',
  'ramblings/webcomic_transcript/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?webcomic_transcript=$matches[1]&wc-api=$matches[3]',
  'ramblings/webcomic_transcript/[^/]+/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'ramblings/webcomic_transcript/[^/]+/attachment/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'ramblings/webcomic_transcript/([^/]+)(/[0-9]+)?/?$' => 'index.php?webcomic_transcript=$matches[1]&page=$matches[2]',
  'ramblings/webcomic_transcript/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'ramblings/webcomic_transcript/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'ramblings/webcomic_transcript/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/webcomic_transcript/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/webcomic_transcript/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'portfolio/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'portfolio/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'portfolio/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'portfolio/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'portfolio/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'portfolio/([^/]+)/trackback/?$' => 'index.php?tn_cstm_portfolio=$matches[1]&tb=1',
  'portfolio/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tn_cstm_portfolio=$matches[1]&feed=$matches[2]',
  'portfolio/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tn_cstm_portfolio=$matches[1]&feed=$matches[2]',
  'portfolio/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?tn_cstm_portfolio=$matches[1]&paged=$matches[2]',
  'portfolio/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?tn_cstm_portfolio=$matches[1]&cpage=$matches[2]',
  'portfolio/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?tn_cstm_portfolio=$matches[1]&wc-api=$matches[3]',
  'portfolio/[^/]+/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'portfolio/[^/]+/attachment/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'portfolio/([^/]+)(/[0-9]+)?/?$' => 'index.php?tn_cstm_portfolio=$matches[1]&page=$matches[2]',
  'portfolio/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'portfolio/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'portfolio/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'portfolio/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'portfolio/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'ramblings/home-page-slide/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'ramblings/home-page-slide/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'ramblings/home-page-slide/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/home-page-slide/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/home-page-slide/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'ramblings/home-page-slide/([^/]+)/trackback/?$' => 'index.php?redter_home_slide=$matches[1]&tb=1',
  'ramblings/home-page-slide/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?redter_home_slide=$matches[1]&feed=$matches[2]',
  'ramblings/home-page-slide/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?redter_home_slide=$matches[1]&feed=$matches[2]',
  'ramblings/home-page-slide/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?redter_home_slide=$matches[1]&paged=$matches[2]',
  'ramblings/home-page-slide/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?redter_home_slide=$matches[1]&cpage=$matches[2]',
  'ramblings/home-page-slide/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?redter_home_slide=$matches[1]&wc-api=$matches[3]',
  'ramblings/home-page-slide/[^/]+/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'ramblings/home-page-slide/[^/]+/attachment/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'ramblings/home-page-slide/([^/]+)(/[0-9]+)?/?$' => 'index.php?redter_home_slide=$matches[1]&page=$matches[2]',
  'ramblings/home-page-slide/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'ramblings/home-page-slide/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'ramblings/home-page-slide/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/home-page-slide/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/home-page-slide/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'robots\\.txt$' => 'index.php?robots=1',
  '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\\.php$' => 'index.php?feed=old',
  '.*wp-app\\.php(/.*)?$' => 'index.php?error=403',
  '.*wp-register.php$' => 'index.php?register=true',
  'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
  '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
  'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
  'comment-page-([0-9]{1,})/?$' => 'index.php?&page_id=3486&cpage=$matches[1]',
  'wc-api(/(.*))?/?$' => 'index.php?&wc-api=$matches[2]',
  'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
  'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
  'comments/page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
  'comments/wc-api(/(.*))?/?$' => 'index.php?&wc-api=$matches[2]',
  'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]',
  'search/(.+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]',
  'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]',
  'search/(.+)/wc-api(/(.*))?/?$' => 'index.php?s=$matches[1]&wc-api=$matches[3]',
  'search/(.+)/?$' => 'index.php?s=$matches[1]',
  'ramblings/author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
  'ramblings/author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
  'ramblings/author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
  'ramblings/author/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?author_name=$matches[1]&wc-api=$matches[3]',
  'ramblings/author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/wc-api(/(.*))?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&wc-api=$matches[5]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/wc-api(/(.*))?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&wc-api=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]',
  'ramblings/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
  'ramblings/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
  'ramblings/([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',
  'ramblings/([0-9]{4})/wc-api(/(.*))?/?$' => 'index.php?year=$matches[1]&wc-api=$matches[3]',
  'ramblings/([0-9]{4})/?$' => 'index.php?year=$matches[1]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&tb=1',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&feed=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&feed=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&paged=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&cpage=$matches[4]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&wc-api=$matches[5]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&page=$matches[4]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  'ramblings/[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  'ramblings/([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]',
  'ramblings/([0-9]{4})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&cpage=$matches[2]',
  '.?.+?/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
  '.?.+?/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
  '.?.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  '.?.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
  '.?.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  '(.?.+?)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1',
  '(.?.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]',
  '(.?.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]',
  '(.?.+?)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]',
  '(.?.+?)/comment-page-([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&cpage=$matches[2]',
  '(.?.+?)/wc-api(/(.*))?/?$' => 'index.php?pagename=$matches[1]&wc-api=$matches[3]',
  '.?.+?/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  '.?.+?/attachment/([^/]+)/wc-api(/(.*))?/?$' => 'index.php?attachment=$matches[1]&wc-api=$matches[2]',
  '(.?.+?)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]',
)
permalink structure

'/ramblings/%year%/%monthnum%/%postname%/'
page permastruct

'%pagename%'
matched rule and query

'portfolio/?$'
matched query

'post_type=tn_cstm_portfolio'
request

'portfolio'
the query

WP_Query::__set_state(array(
   'query' => NULL,
   'query_vars' => 
  array (
  ),
   'tax_query' => NULL,
   'meta_query' => false,
   'queried_object' => NULL,
   'queried_object_id' => NULL,
   'request' => NULL,
   'posts' => NULL,
   'post_count' => 0,
   'current_post' => -1,
   'in_the_loop' => false,
   'post' => NULL,
   'comments' => NULL,
   'comment_count' => 0,
   'current_comment' => -1,
   'comment' => NULL,
   'found_posts' => 0,
   'max_num_pages' => 0,
   'max_num_comment_pages' => 0,
   'is_single' => false,
   'is_preview' => false,
   'is_page' => false,
   'is_archive' => false,
   'is_date' => false,
   'is_year' => false,
   'is_month' => false,
   'is_day' => false,
   'is_time' => false,
   'is_author' => false,
   'is_category' => false,
   'is_tag' => false,
   'is_tax' => false,
   'is_search' => false,
   'is_feed' => false,
   'is_comment_feed' => false,
   'is_trackback' => false,
   'is_home' => false,
   'is_404' => false,
   'is_comments_popup' => false,
   'is_paged' => false,
   'is_admin' => false,
   'is_attachment' => false,
   'is_singular' => false,
   'is_robots' => false,
   'is_posts_page' => false,
   'is_post_type_archive' => false,
   'query_vars_hash' => false,
   'query_vars_changed' => true,
   'thumbnails_cached' => false,
))
template redirect filters

array (
  10 => 
  array (
    'wp_old_slug_redirect' => 
    array (
      'function' => 'wp_old_slug_redirect',
      'accepted_args' => 1,
    ),
    'redirect_canonical' => 
    array (
      'function' => 'redirect_canonical',
      'accepted_args' => 1,
    ),
    'woocommerce_template_redirect' => 
    array (
      'function' => 'woocommerce_template_redirect',
      'accepted_args' => 1,
    ),
    'woocommerce_save_password' => 
    array (
      'function' => 'woocommerce_save_password',
      'accepted_args' => 1,
    ),
    'woocommerce_save_address' => 
    array (
      'function' => 'woocommerce_save_address',
      'accepted_args' => 1,
    ),
  ),
  11 => 
  array (
    'wp_shortlink_header' => 
    array (
      'function' => 'wp_shortlink_header',
      'accepted_args' => 0,
    ),
  ),
  20 => 
  array (
    'woocommerce_track_product_view' => 
    array (
      'function' => 'woocommerce_track_product_view',
      'accepted_args' => 1,
    ),
  ),
  1000 => 
  array (
    'wp_redirect_admin_locations' => 
    array (
      'function' => 'wp_redirect_admin_locations',
      'accepted_args' => 1,
    ),
  ),
  99999 => 
  array (
    'debug_404_template_redirect' => 
    array (
      'function' => 'debug_404_template_redirect',
      'accepted_args' => 1,
    ),
  ),
)
template file selected

''

It appears that the value for template file selected is not set. When line 147 is commented out, it correctly locates the template files in the plugin folder:

template file selected

'/Users/tak/Sites/lauraterry/wp-content/plugins/work-portfolio-plugin/templates/archive-tn_cstm_portfolio.php'

Which makes me think... it's definitely a conflict with the way that the template_include filter is handled. And that something is conflicting when it's called by another plugin?

  1. When I copied the archive and single templates using WP's inbuilt custom post type template naming conventions into my theme folder:

archive-custom_post_type_name.php single-custom_post_type_name.php

The query was able to correctly match the custom templates and use them. While this solves, at least this particular issue, I wonder if this bug would effect other sites using plugins with the same template_includes filter?