Custom Post Types and rewrite rules – One CPT works and a cloned one doesn’t
Custom Post Types and rewrite rules – One CPT works and a cloned one doesn’t
Custom Post Types and rewrite rules – One CPT works and a cloned one doesn’t
Custom Rewrite Tag Structure
Thanks cybmeta I have installed a plugin called Allow Duplicate Slugs By John Blackbourn and fixed issue! also I come across another function.php solution too.
rewrite rule of post when accessed from archives pages
Finally got this working nicely, this specific issue was just down to not flushing the rewrite rules (gets me everytime!) so it was fixed by simply navigating to the ‘Permalinks’ page in the WP admin area.
This exact piece of code works, the reason for redirect was some other plugin. To create as many child pages you want dynamically you just need to this just hook it to ‘init’ hook. add_action(‘init’,’my_custom_rewrite_rules’ ); function my_custom_rewrite_rules(){ add_rewrite_tag( ‘%make%’, ‘([^/]+)’ ); add_rewrite_rule(‘^cars/([^/]+)/?’,’index.php?make=$matches[1]’,’top’); //or To go to a published page. add_rewrite_rule(‘^cars/([^/]+)/?’,’index.php?pagename=page-slug&make=$matches[1]’,’top’); } If you want … Read more
Thanks @cybmeta for your hint. I searched my theme and found an other flush_rewrite_rules(true); on the init hook. I removed this and now the rule is being remembered. Seemingly, calling the function twice is breaking something. Doesn’t really make sense to me, but it works now, so whatever 🙂
Ok, resolved this. I am now registering the taxonomy and terms on the init hook rather than wp_loaded and that seems to have fixed things. I will accept this answer as soon as I can.
It sounds like you misunderstand how to add rewrite rules as your structure is relatively common and should not require flushing the rules on every page load. The impact depends on your set of rewrite rules, and the codex is somewhat outdated and I don’t think it is as bad as it used to be … Read more
add_rewrite Rule