This worked in the end, not sure why I was not getting anything showing up in the re-write rules initially but this worked.
with yacht_name_id added in as a filter
You're missing the WP $matches syntax for the regex that gets matched.
I think you want /? on the end too.
Easiest way I found to test was to temporarily put flush_rewrite_rules() in whilst testing, then you don't have to do anything else. I have a similar regex which sends /foo/catname/ to index.php?taxonomy=category&term=catname, here's what I used ...
I just did a test and it seems like the rewrite rules imply ^ if you do not specify it. In my test I found:
rule 'foo' matched url 'foo'
rule '^foo' matched url 'foo'
rule 'foo' did not match url 'afoo'
rule '^foo' did not much url 'afoo'
rule '.*foo' matched url 'afoo'
So i had to explicitly add some matching regex at the start for it to match extra ...
This code produces the right structure but the post can't be found
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 rules.
First, you need to register the %office% rewrite tag:
// First, add the rewrite tag.
add_rewrite_tag( '%office%', '([^/]+)', 'post_type=office_members&office_name=' );
// Then call add_permastruct().
add_permastruct( 'office_members', ... );
Then, add the custom office_name arg to the public query vars so that WordPress reads/parses it from the URL:
It's quite easy, actually:
Change the generated permalink structure so that it ends with the post ID and not the post slug (but it still contains the post slug):
// After you registered the post type:
register_post_type( 'ex_article', $args );
// .. run this code:
$wp_rewrite->extra_permastructs['ex_article']['struct'] = 'sa/%...
Our custom rewrite rule works for top-level services but not child
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
// Here, add the &service=$matches
I want to pass the following URL Parameters at the end of every image URL in WordPress site: ?f=auto
I am using WooCommerce and wanted to add following URL Parameters at the end of every image in my WordPress site.
Can you please help me with that?