Rewrite rule regex help required

Our custom rewrite rule works for top-level services but not child services. Your rewrite rule, or the query (the second parameter for add_rewrite_rule()) is just missing a service query: add_rewrite_rule( // wrapped for brevity ‘^consultancy/(.*)/?’, // Here, add the &service=$matches[1] ‘index.php?post_type=service&name=$matches[1]&service=$matches[1]’, ‘top’ ); But, why don’t you just use consultancy as the rewrite slug when … Read more

Custom permalink structure for custom post types including multiple taxonomy

This code produces the right structure but the post can’t be found (404) That is because the custom rewrite tags (%filter_1% and %filter_2%) appeared as-is in the generated rewrite rules (in the database). So you need to register the tags so that they’re replaced with the proper RegEx (regular expression) pattern when WordPress (re-)generates the … Read more

Category permalinks don’t work even after flushing

The default WP category is only set-up to show posts out of the box. You should be able to expand this by doing something like the below in your functions.php: // Order course archive and taxonomy views function adjust_main_query($query){ if ( ! is_admin() && is_category() && is_category() && $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘post’, … Read more

Rewrite/Change custom taxonomy slug

Try using the below code to overwrite arguments of already registered taxonomies. function wp_modify_taxonomy() { // get the arguments of the already-registered taxonomy $custom_category_args = get_taxonomy( ‘genre’ ); // make changes to the args $custom_category_args->rewrite[‘slug’] = ‘chambers’; $custom_category_args->rewrite[‘with_front’] = false; // re-register the taxonomy register_taxonomy( ‘genre’, ‘chambers’, (array) $custom_category_args ); } add_action( ‘init’, ‘wp_modify_taxonomy’, 11 … Read more