Custom Content Type Manger (CCTM) hierarchical post type issue workaround?
Since the release of WordPress 3.7 there has been a problem with hierarchical post types in Custom Content Type Manager (CCTM). Level 2 pages have been showing as 404 errors and the issue was raised in this thread. the gout code on foot Understandably, the plugin’s author can’t react to every surprise change in the architecture of WordPress – especially when the plugin is free.
Because I ABSOLUTELY NEEDED THIS TO WORK I was willing to try anything including updating the plugin itself. Then I ran across this post that showed a semi-workaround, but it only worked on the top level posts. So with a little addition to that code I was finally able to get the 2nd-level pages to work!
For simplicity’s sake (and because I couldn’t figure out any other way to do it) I just created one function and one hook for each post type. This code was added to my functions.php file.
/*------------------------------------------- Trying to fix CCTM issue -------------------------------------------*/ /*------------------------------------------- Markets -------------------------------------------*/ function markets_add_rewrite_rules($aRules) { $aNewRules = array('markets/(.+?)(/[0-9]+)?/?$' => 'index.php?post_type=markets&name=$matches[1]&page=$matches[2]'); $aRules = $aNewRules + $aRules; return $aRules; } if ( !is_admin() ) { add_filter('rewrite_rules_array', 'markets_add_rewrite_rules'); } /*------------------------------------------- Services -------------------------------------------*/ function services_add_rewrite_rules($aRules) { $aNewRules = array('services/(.+?)(/[0-9]+)?/?$' => 'index.php?post_type=services&name=$matches[1]&page=$matches[2]'); $aRules = $aNewRules + $aRules; return $aRules; } if ( !is_admin() ) { add_filter('rewrite_rules_array', 'services_add_rewrite_rules'); }