Hierarchical taxonomies in permalink cause 404 for sub term archive
I’ve not reviewed your code, just a quick thought: Have you tried Going to Settings => Permalinks and just clicking ‘Save Changes‘? That flushes the rewrite cache.
I’ve not reviewed your code, just a quick thought: Have you tried Going to Settings => Permalinks and just clicking ‘Save Changes‘? That flushes the rewrite cache.
You have not stated if COUNTRY and CITY are categories, tags or something else. This information would help in giving you a complete answer. This is just an example of how it can be done. //Add a location variable to the post type’s rewrite rule function my_post_type_args( $args, $post_type ) { if ( ‘my_post_type’ == … Read more
You can remove the offending rewrite rule manually from the .htaccess file, in the web site’s root. Thanks, “mmm”!
You set ‘has_archive’ => true, which will make your post type archive URL localhost:3005/en/makeup_section/, as it will use your post type slug if you do not specify a string. Change it to ‘has_archive’ => ‘sections’ to place it at localhost:3005/en/sections/.
I handled this with a pre_get_posts hook (thanks, @Milo), passing in the URL part that corresponds to the slug I need. Hope this helps someone down the road. Improvements are welcome. Thanks. function filter_team_news_archives_by_sport_taxonomy($query) { if (is_post_type_archive(‘team-news’) && $query->is_main_query()){ // Get $sport_slug from URL — https://stackoverflow.com/a/36002190/4107296 $url = (isset($_SERVER[‘HTTPS’]) ? “https” : “http”) . “://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”; … Read more
I found solution – I needed to run flush_rules() method at least once to clean cache. //Ensure the $wp_rewrite global is loaded global $wp_rewrite; //Call flush_rules() as a method of the $wp_rewrite object $wp_rewrite->flush_rules( false );
Flush rewrite rules after a term is edited
Managed to get this working with a little help from Debug This plugin and some little hints from similar questions. At least so far, after some quick testing, I haven’t come across any negative side effects. The problem, if I understood correctly, is that if I have my cpt rewrite set to same slug as … Read more
I just realized i used different kind of rewriting which didn’t require @Jacob’s codes (using add_rewrite_endpoint) add_action(‘init’, ‘wpse42279_add_endpoints’); function wpse42279_add_endpoints() { add_rewrite_endpoint(‘play’, EP_PERMALINK); } And then i used this conditionals on the single page: global $post; $pid = $post->ID; $var = get_query_var( ‘play’ ); if( !empty($var) and $var == $pid) : // do stuff endif; … Read more
Nicolais Tip got me on the right track; Here is the working code: // add a query_var first add_filter(“query_vars”, function($vars) { $vars[] = “myTheme_podcast_time”; return $vars; }); add_filter(“rewrite_rules_array”, function($rules) { $newRules = array(); $newRules[“(.*)/time/([\d|\:]+)s?$”] = ‘index.php?name=$matches[1]&myTheme_podcast_time=$matches[2]’; $merged = array_merge($newRules, $rules); return $merged; }); And then in single.php: $time = get_query_var(“myTheme_podcast_time”); // do stuff