Custom Permalinks
Issue with templates for Custom Post Type (2 posts)

  1. ThemesWPfree.net
    Posted 3 years ago #


    I'm having issues with single post template for my custom post type after enabling Custom Permalinks plugin. It appears to be overwriting custom post type template single-{custom_post_type}.php and instead uses single.php.

    When I disable Custom Permalinks plugin everything works fine.

    Any ideas how to fix it or a way around to this problem would be appreciated.



  2. ThemesWPfree.net
    Posted 3 years ago #

    If anyone would be interested here is a work around solution which I'm using for now.

    It's a filter located in functions.php file, which overwrites default template file if the page has a 'post' type and URL includes custom-post-type slug.

    // Template selection
    function custom_template_include($incFile) {
    $url = $_SERVER['REQUEST_URI'];

    if ( (get_post_type() == "post") && (strpos($url, "/custom-post-type-slug/") !== false) ) {
    if (have_posts()) {
    $file = TEMPLATEPATH.'/single-custom-post-type.php';
    if (file_exists($file)) {
    $incFile = $file;
    } else {
    $wp_query->is_404 = true;
    } else {
    $wp_query->is_404 = true;

    return $incFile;
    add_filter('template_include', 'custom_template_include');

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Permalinks
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic