How to rewrite custom post type URL for multiple depths instead of one specific depth

After testing countless different structures i came up with this. It’s manual work specifying each category but gives me more control. If someone comes up with a better solution, please let me know. function mmp_rewrite_rules($rules) { //Product structure $newRules[‘product/(.+)/(.+)/(.+)/(.+)/?$’] = ‘index.php?products=$matches[4]’; //The above structure only works of the postname is the 5th uri segment //It’s … Read more

Change the custom post type permalink

You can use rewrite arg in register_post_type. You can have custom post type name different then rewrite slug. For example here is the sample code with custom post type project and it shows pages with http://shaowtriger.com/brands/naim/ Notice rewrite in $args add_action( ‘init’, ‘codex_brand_init’ ); function codex_brand_init() { $labels = array( ‘name’ => _x( ‘Brands’, ‘post … Read more

Remove base slug in CPT & CT, use CT in permalink

I copied your code as-is above, pasted it into the twentysixteen theme, and changed just the post type rewrite slug from review/%brand% to %brand%. This resulted in both the term archive and review posts having your desired URL structure and successfully displaying. Now the bad news is that the rewrite rules generated for the taxonomy … Read more

What is the action or filter for changing permalink in Edit Post/Page?

You can use the the_permalink filter to modify permalinks. Take a look at the function reference for the same. Code sample from the docs: Append the query string for the current page to permalink URLs function append_query_string($url) { return add_query_arg($_GET, $url); } add_filter(‘the_permalink’, ‘append_query_string’); More information on permalinks: Here (StackOverflow) Here (Elegant Themes) And here … Read more

Pros and cons of using [taxonomy name] in place of [category name]?

For the SEO part you might get better answers on the Pro Webmasters Stack Exchange. I will focus on the performance. From your example I assume your permalink structure was %category%/%postname%/. Because of the way WordPress parses the incoming URL, this will result in verbose page rules, which means that each page (not post) you … Read more