• Good Afternoon,

    I’m having an issue where the filter for the CPT template callback is not getting called but if I put any old post type in there like ‘single_template’ it’s getting called just fine.

    Any idea why?

    Thanks!

    
    register_post_type('stoneblue-thinkific', $rpt_arg);
    
    
    $this->loader->add_filter('archive-stoneblue-thinkific_template', $plugin_public, 'archive_stoneblue_thinkific');
    $this->loader->add_filter('single-stoneblue-thinkific_template', $plugin_public, 'single_stoneblue_thinkific');
    
    $this->loader->add_filter('single_template', $plugin_public, 'single_stoneblue_thinkific');
    $this->loader->add_filter('archive_template', $plugin_public, 'archive_stoneblue_thinkific');
    
    

    So for a single post and an archive it calls the cb and loads the template located in the plugin dir. But for CPT nada. The CB doesn’t get called.

    The CPT is there, I can create new CPTs and see the list in the admin area wp-admin/edit.php?post_type=stoneblue-thinkific

    That all works great just not able to load the CPT templates. Well I can load the CPT templates with single post and archive post types but not the CPTs.

    • This topic was modified 6 years, 7 months ago by Ken Stone.
    • This topic was modified 6 years, 7 months ago by Ken Stone.
Viewing 15 replies - 1 through 15 (of 19 total)
  • Moderator bcworkz

    (@bcworkz)

    There is no filter tag named "single-{$post_type}_template". The template loader will load template files named "single-{$post_type}.php", but there is no similar filter. There is a "{$type}_template" filter, but $type is not a post type. $type is limited to values like ‘archive’, ‘search’, ‘single’, ‘singular’, etc.

    If your template files are correctly named, such as single-stoneblue-thinkific.php, they will be used for your CPT. If you want to change the template loaded, you can use the ‘single_template’ filter to return a path/file to the desired template. Likewise for ‘archive_template’ filter.

    You can fiddle with the template hierarchy with the "{$type}_template_hierarchy" filter. To determine if the template being loaded is for your post type here or for "{$type}_template", you’ll need to examine the values in the passed $templates array. For example, for your CPT, somewhere in the $templates array will be the value ‘single-stoneblue-thinkific.php’.

    Thread Starter Ken Stone

    (@wpstoneblue)

    Thanks! I will try the {$type}_template_hierarchy filter now to explore that possibility.

    My goal is to load the single and archive templates for the CPT from the plugin directory.

    I was attempting to following along with this https://wpshout.com/hacking-the-wordpress-template-hierarchys/ example.

    Thread Starter Ken Stone

    (@wpstoneblue)

    It’s just not my day, that’s all there is to it…

    Backing up a bit the CPT is defined as:

     $rpt_arg = array(
       'labels' => array(
          'name'            => __( 'Thinkific Course', $this->plugin_name ),
          'singular_name'   => __( 'Thinkific Course', $this->plugin_name ),
          'menu_na          => __( 'Thinkific Courses', $this->plugin_name ),
          'name_admin_bar'  => __( 'Thinkific Courses', $this->plugin_name ),
          'add_new'         => __( 'Thinkific Course', $this->plugin_name ),
          'add_new_item'    => __( 'Thinkific Course', $this->plugin_name ),
          'new_ite          => __( 'Thinkific Course', $this->plugin_name ),
          'not_found'       => __( 'Thinkific Course  Not Found', $this->plugin_name ),
          'all_items'       => __( 'All Thinkific Courses', $this->plugin_name ),
                            ),
        'public'              => true,
        'show_in_menu'        => true,
        'has_archive'         => true,
        'supports'            => array('title', 'editor', 'thumbnail'),
        'rewrite'             => true,
        'map_meta_cap'        => true,
        'register_meta_box_cb'  => array($this, 'add_meta_boxes')
        );
    
    $post_type = register_post_type('stoneblue-thinkific', $rpt_arg);

    single_template and archive_template filters are not getting called for the CPT so appears that I can’t use them.

    I really don’t want to use template_include but …

    Thread Starter Ken Stone

    (@wpstoneblue)

    Ugh, could this be because I failed to visit the settings – perma links admin page ?

    Moderator bcworkz

    (@bcworkz)

    Failing to visit the permalinks screen or flush rewrite rules will certainly prevent your CPT from being properly queried. It doesn’t have any direct bearing on whether template filters fire. However, if the query fails, the 404 template is loaded and the remaining template determination sequence with its related filters are all passed over. Only the generic “template_include” filter still fires.

    WP will only search for templates in the theme folder (active or parent and child). In the case of the page post type, it’s possible to finagle template loading from plugins because template paths are stored in post meta. AFAIK there is no way to induce the same behavior for CPTs. Using pages instead of your CPT may or may not be a viable option.

    If you cannot make use of pages, you will need to make use of one of the template filters to override the default theme template search. ‘single_template’ and ‘archive_template’ should fire for related CPT queries. I take it these are now working since you now have your CPT being correctly queried. ‘template_include’ isn’t that much worse than one of the more specific filters. Its only drawback is its lack of specificity. It does have the advantage of overriding any template determination. The ‘single_template’ filter can only override queries where is_single() is true. Similar for ‘archive_template’.

    Thread Starter Ken Stone

    (@wpstoneblue)

    Failing to visit the permalinks screen or flush rewrite rules will certainly prevent your CPT from being properly queried. It doesn’t have any direct bearing on whether template filters fire. However, if the query fails, the 404 template is loaded and the remaining template determination sequence with its related filters are all passed over. Only the generic “template_include” filter still fires.

    Yes, this is exactly what I was seeing the 404 and only the template_include filter firing.

    For the archive I ended up with the following working code and very similar for the single:

     public function stoneblue_thinkific_archive_template($template){
    
        global $post;
    
        if ($post->post_type == "stoneblue-thinkific" 
           && $template !== locate_template(array("archive-stoneblue-thinkific.php"))){
                            
           $file = dirname(dirname(__FILE__)) . '/stoneblue-thinkific.php';
                            
           $template = plugin_dir_path($file) . 'templates/archive-stoneblue-thinkific.php';
        }
    
    }
    Thread Starter Ken Stone

    (@wpstoneblue)

    Now I want to provide the user the ability to choose the link structure for the CPT.

    So instead of having //websitecom/stoneblue-thinkific/basket-weaving-101 I’d like the stoneblue-thinkifici portion to be a plugin setting.

    So I’m looking to the rewrite rules for this. What I have so far is sort of working.
    If I set base_url in the options table to ‘online-courses’ then I’m able to navigate to //webaddresscom/online-courses/basket-weaving-101 but //webaddresscom/online-courses (the archive) only works if the previous page was the single (basket weaving) page.

     public function rewrite(){
    
          $options = get_option($plugin_name);
    
          $base_url = $options['base_url'];
    
          add_rewrite_rule($base_url . '/?([^/]*)', '/index.php?post_type=stoneblue-thinkific/', 'top');
          add_rewrite_tag( '%course%', '([^/]+)' );
          add_permastruct( 'course', $base_url . '/%course%' );
    
    }
    • This reply was modified 6 years, 7 months ago by Ken Stone.
    • This reply was modified 6 years, 7 months ago by Ken Stone.
    • This reply was modified 6 years, 7 months ago by Ken Stone.
    Thread Starter Ken Stone

    (@wpstoneblue)

    I’m now using the post_type_link hook to modify the links which is really cool but the add_rewrite_rule still has me a bit baffled. I’ll go walk the dog now and see if that helps..

    public function rewrite(){
            
      $options = get_option($this->plugin_name);
    
      $thinkific_rewrite = $options['thinkific_rewrite'];
    
      add_rewrite_rule($thinkific_rewrite . '/?([^/]*)', '/index.php?post_type=stoneblue-thinkific&name=$matches[1]', 'top');
    
    }
    • This reply was modified 6 years, 7 months ago by Ken Stone.
    Thread Starter Ken Stone

    (@wpstoneblue)

    Even though the rewrite rule may not be the correct one it should still be in the rules array?

    rules: array (
      '^wp-json/?$' => 'index.php?rest_route=/',
      '^wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
      '^index.php/wp-json/?$' => 'index.php?rest_route=/',
      '^index.php/wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
      'stoneblue-thinkific/?$' => 'index.php?post_type=stoneblue-thinkific',
      'stoneblue-thinkific/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'stoneblue-thinkific/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'stoneblue-thinkific/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]',
      'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
      'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
      'category/(.+?)/embed/?$' => 'index.php?category_name=$matches[1]&embed=true',
      'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
      'category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
      'tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
      'tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
      'tag/([^/]+)/embed/?$' => 'index.php?tag=$matches[1]&embed=true',
      'tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
      'tag/([^/]+)/?$' => 'index.php?tag=$matches[1]',
      'type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]',
      'type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]',
      'type/([^/]+)/embed/?$' => 'index.php?post_format=$matches[1]&embed=true',
      'type/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?post_format=$matches[1]&paged=$matches[2]',
      'type/([^/]+)/?$' => 'index.php?post_format=$matches[1]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      'stoneblue-thinkific/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true',
      'stoneblue-thinkific/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1',
      'stoneblue-thinkific/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]',
      'stoneblue-thinkific/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'stoneblue-thinkific/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'stoneblue-thinkific/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '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]',
      'embed/?$' => 'index.php?&embed=true',
      'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
      '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/embed/?$' => 'index.php?&embed=true',
      '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/(.+)/embed/?$' => 'index.php?s=$matches[1]&embed=true',
      'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]',
      'search/(.+)/?$' => 'index.php?s=$matches[1]',
      'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
      'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
      'author/([^/]+)/embed/?$' => 'index.php?author_name=$matches[1]&embed=true',
      'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
      'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
      '([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]',
      '([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]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&embed=true',
      '([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]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]',
      '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
      '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
      '([0-9]{4})/embed/?$' => 'index.php?year=$matches[1]&embed=true',
      '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',
      '([0-9]{4})/?$' => 'index.php?year=$matches[1]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1',
      '([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]&name=$matches[4]&feed=$matches[5]',
      '([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]&name=$matches[4]&feed=$matches[5]',
      '([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]&name=$matches[4]&paged=$matches[5]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&cpage=$matches[5]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]',
      '([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]',
      '([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]',
      '.?.+?/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '(.?.+?)/embed/?$' => 'index.php?pagename=$matches[1]&embed=true',
      '(.?.+?)/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]',
      '(.?.+?)(?:/([0-9]+))?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]',
    )
    Moderator bcworkz

    (@bcworkz)

    Yes it should. Don’t forget to visit the permalinks screen after altering rewrite rules! ?? (or call flush_rewrite_rules()))

    Regexp alone can be confusing enough, combined with rewrite rules and confusion is practically mandatory. One possible complication is when other rules match the request before yours. With a custom base, that is not likely, but it’s something to keep in mind. Using the ‘top’ argument helps. Adding your callback to the action hook with a small priority number so your rule occurs first can make the difference. Just a general tip, probably wouldn’t make a difference here.

    I assume that $thinkific_rewrite contains the desired base term. If it should always be the very first term in a request, it should be preceded with regexp ^. Your regexp before the capture term is a little confused. It still should work as desired, but it could be applied where it shouldn’t. Specifically, you don’t want the ? where it is, it indicates the preceding / is optional.

    If you want the capture term to be the last term in a request, it should be followed with /?$. You do want the terminal slash to be optional, as it’s frequently omitted by users. It may be I’m misinterpreting what you are trying to achieve, but I think the regexp for your rewrite rule should be more like this:
    '^' . $thinkific_rewrite . '/([^/]*)/?$'

    If $thinkific_rewrite == ‘course’, a request of example.com/course/php-coding/ will result in a stoneblue-thinkific post titled “PHP Coding” being returned by the query. A request of example.com/foo/course/php-coding/ will not match, nor would example.com/course/php-coding/bar/

    Understanding regexp is essential to successful rewrite rules. Getting your rule listed first helps. Visiting the permalinks screen is also essential ??

    Thread Starter Ken Stone

    (@wpstoneblue)

    flush_rewrite_rules is being called on activate and deactivate and rewrite on init. I saw somewhere that adding the rewrite in the activate just before the flush is a good idea but I don’t understand why.

    I finally took the plunge and purchased jfriedl’s Mastering Regular
    Expressions. I’m on my way…

    Thank you very much for the regex. I’m going to give these a try and with my new understanding of regex maybe today is the day this gets completed.

    Thread Starter Ken Stone

    (@wpstoneblue)

    What if I used the rules array and copied the entries with the CPT name at the beginning of the rule and replaced the CPT name with the name the user configures then pushed those back onto the rules array?

    Thread Starter Ken Stone

    (@wpstoneblue)

    So I really thought I was finished after adding the new rules to the rules array with this being the new rules array (some items deleted for brevity).

    rules: array (
      'stoneblue-thinkific/?$' => 'index.php?post_type=stoneblue-thinkific',
      'stoneblue-thinkific/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'stoneblue-thinkific/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'stoneblue-thinkific/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      'stoneblue-thinkific/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true',
      'stoneblue-thinkific/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1',
      'stoneblue-thinkific/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]',
      'stoneblue-thinkific/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'stoneblue-thinkific/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'stoneblue-thinkific/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      'online-courses/?$' => 'index.php?post_type=stoneblue-thinkific',
      'online-courses/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'online-courses/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'online-courses/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]',
      'online-courses/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'online-courses/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'online-courses/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'online-courses/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      'online-courses/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true',
      'online-courses/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1',
      'online-courses/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'online-courses/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'online-courses/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]',
      'online-courses/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]',
      'online-courses/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]',
      'online-courses/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'online-courses/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'online-courses/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'online-courses/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
    )

    using this code:

     
    public function rewrite_rules_array($rules){
    
          $options = get_option($this->plugin_name);
    
          $thinkific_rewrite = $options['thinkific_rewrite'];
    
          foreach($rules as $rule => $replace){
    
                 if(preg_match('/^stoneblue-thinkific/', $rule) == 1){
                          $newrule = preg_replace('/^stoneblue-thinkific/', $thinkific_rewrite, $rule);
                                   
                          $rules[$newrule] = $replace;
                 }
    
          }
            
          return $rules;
    
    }
    Thread Starter Ken Stone

    (@wpstoneblue)

    Apparently order matters in the rules array.

    Changed the code to:

     
    public function rewrite_rules_array($rules){
    
      $options = get_option($this->plugin_name);
    
      $thinkific_rewrite = $options['thinkific_rewrite'];
    
      foreach($rules as $rule => $replace){ 
    
          if(preg_match('/^stoneblue-thinkific/', $rule) == 1){
                  
            $newrule = preg_replace('/^stoneblue-thinkific/', $thinkific_rewrite, $rule)
                          
            $rrules[$newrule] = $replace;
                  
          }
                  
          $rrules[$rule] = $replace;
          
        }
         
        return $rrules;
    }

    Which produces a new rules array:

    rules: array (
      '^wp-json/?$' => 'index.php?rest_route=/',
      '^wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
      '^index.php/wp-json/?$' => 'index.php?rest_route=/',
      '^index.php/wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
      'online-courses/?$' => 'index.php?post_type=stoneblue-thinkific',
      'stoneblue-thinkific/?$' => 'index.php?post_type=stoneblue-thinkific',
      'online-courses/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'stoneblue-thinkific/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'online-courses/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'stoneblue-thinkific/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]',
      'online-courses/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]',
      'stoneblue-thinkific/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]',
      'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
      'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
      'category/(.+?)/embed/?$' => 'index.php?category_name=$matches[1]&embed=true',
      'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
      'category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
      'tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
      'tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
      'tag/([^/]+)/embed/?$' => 'index.php?tag=$matches[1]&embed=true',
      'tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
      'tag/([^/]+)/?$' => 'index.php?tag=$matches[1]',
      'type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]',
      'type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]',
      'type/([^/]+)/embed/?$' => 'index.php?post_format=$matches[1]&embed=true',
      'type/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?post_format=$matches[1]&paged=$matches[2]',
      'type/([^/]+)/?$' => 'index.php?post_format=$matches[1]',
      'online-courses/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'online-courses/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'online-courses/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'online-courses/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      'stoneblue-thinkific/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      'online-courses/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true',
      'stoneblue-thinkific/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true',
      'online-courses/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1',
      'stoneblue-thinkific/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1',
      'online-courses/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'online-courses/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]',
      'online-courses/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]',
      'stoneblue-thinkific/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]',
      'online-courses/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]',
      'online-courses/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]',
      'stoneblue-thinkific/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]',
      'online-courses/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'stoneblue-thinkific/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      'online-courses/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'stoneblue-thinkific/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      'online-courses/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      'online-courses/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'stoneblue-thinkific/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      'online-courses/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      'stoneblue-thinkific/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '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]',
      'embed/?$' => 'index.php?&embed=true',
      'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
      '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/embed/?$' => 'index.php?&embed=true',
      '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/(.+)/embed/?$' => 'index.php?s=$matches[1]&embed=true',
      'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]',
      'search/(.+)/?$' => 'index.php?s=$matches[1]',
      'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
      'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
      'author/([^/]+)/embed/?$' => 'index.php?author_name=$matches[1]&embed=true',
      'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
      'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
      '([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]',
      '([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]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&embed=true',
      '([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]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
      '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]',
      '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
      '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
      '([0-9]{4})/embed/?$' => 'index.php?year=$matches[1]&embed=true',
      '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',
      '([0-9]{4})/?$' => 'index.php?year=$matches[1]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1',
      '([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]&name=$matches[4]&feed=$matches[5]',
      '([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]&name=$matches[4]&feed=$matches[5]',
      '([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]&name=$matches[4]&paged=$matches[5]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&cpage=$matches[5]',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
      '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]',
      '([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]',
      '([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]',
      '.?.+?/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true',
      '(.?.+?)/embed/?$' => 'index.php?pagename=$matches[1]&embed=true',
      '(.?.+?)/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]',
      '(.?.+?)(?:/([0-9]+))?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]',
    )

    Going to walk to the dog now and move on to the next task finally!!!

    Thanks for your help!!!

    Really appreciate it !!!

    Enjoy today !!!

    Thread Starter Ken Stone

    (@wpstoneblue)

    I’m on the fence about maintaining the old CPT name rules (stoneblue-thinkific) in the rules array.

    thoughts?

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘add_filter(single-{CPT}_template’ is closed to new replies.