14:08
New rewrite rules don't get added to .htaccess by default, WordPress uses its own array that it checks
Smart :)
Its much larger than just what's in .htaccess
And you can analyze it with my plugin
The new rule should be there, at the top
Di I have to download your plugin?
*Do
You can't really download it yet, just create a new file in wp-content/plugins/ and copy the code from my answer in it
4
A: A tool to analyze rewrite rules?

Jan FabryWell what a coincidence that you ask this, Jan! Just today I had time on a long train journey and decided to write a Rewrite Analyzer plugin, one that parses your rewrite rules and highlights the query variables. It can be extended to simplify the regex so mere mortals can understand them too, bu...

(I might add it to the plugin repo later today)
Right... huge list... let's see....
designers/attachment/([^/]+)/?$

attachment: ([^/]+)

designers/attachment/([^/]+)/trackback/?$

attachment: ([^/]+)
tb: 1

designers/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$

attachment: ([^/]+)
feed: (feed|rdf|rss|rss2|atom)

designers/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$

attachment: ([^/]+)
feed: (feed|rdf|rss|rss2|atom)

designers/attachment/([^/]+)/comment-page-([0-9]{1,})/?$

attachment: ([^/]+)
cpage: ([0-9]{1,})

(designers)/trackback/?$

pagename: (designers)
tb: 1
14:16
It looks like those are the standard rules for the designers page, not yet the rule we added
So we need to figure out why the rewrite rules are not applied.
There is nothing at the top of that list, designers/([^/]+)/??
Indeed, then it is not added. Is the add_rewrite_rule() function called? Can you put a var_dump(__FUNCTION__) above it?
It should display at every page load
This is at the top:

robots.txt$

robots: 1

.*wp-atom.php$

feed: atom

.*wp-rdf.php$

feed: rdf

.*wp-rss.php$

feed: rss

.*wp-rss2.php$

feed: rss2

.*wp-feed.php$

feed: feed

.*wp-commentsrss2.php$

feed: rss2
withcomments: 1

christmas-calendar/attachment/([^/]+)/?$

attachment: ([^/]+)

christmas-calendar/attachment/([^/]+)/trackback/?$

attachment: ([^/]+)
tb: 1
And certainly if you open the permalinks page
var_dump(FUNCTION) -> string(12) "wpa5413_init"
14:20
OK, great, so it gets called
Now, go to the permalinks page, and click "Save" to be sure
If it does not show up in the list now, we can start adding filters to figure out where it goes wrong
Nothing new at the top of the list
OK, then hook into the rewrite_rules_array filter, and var_dump() the contents of it (be sure to return the value too, otherwise we empty it)
add_filter( 'rewrite_rules_array', 'dump_it' ); function dump_it($value){var_dump($value);return $value;}
Something like that
Usingthat, I get a huge list of rewrite rules. Basically thesame as in the list in your plugin.
OK, this means our add_rewrite_rule() is not effective. Very bizarre. But we can use this filter instead. That's was your update 3 code does.
Take the rules array you get, add your designer rule on top, and return the new array
Right. I've updated the code in example 3. Now I get something new at the top of my list.

`(designers)/(d*)$
pagename: designers
designer: (designers)
`
But I still get a 404
14:34
What is the (d*)? Is it a d with a slash before it? (\d) Because this matches only numbers, not the text slug we want to use
$newrules['(designers)/(\d*)$'] = 'index.php?pagename=designers&designer=$matches[1]';
You should use the ([^/]+) version, this matches anything up to the next /.
I have no idea what th \d is.... :)
ok
So it will become: $newrules['designers/([^/]+)/?'] = ...
and you can use designer or designer_slug or whatever in the right hand part, just make sure you use the same thing in the query_vars filter
Blody h**! That worked! :)
I'm using this now: $newrules['^designers/([^/]*)$'] = 'index.php?pagename=designers&designer=$matches[1]';
So.... any chanse of passing along the $bid? :)
14:38
Voila - normally the add_rewrite_rule() thing should give you the same result, but for some reason it did not work for you
@Steven You can include it, but then of course you will see it in your URL
bah - I'll just rewrite the code to fetch correct designer based on unique slug that I've aded to DB :)
Most of the time they put it before the slug, so if you mistype the slug, or leave it off (shortlink for Twitter?), it will still work
it's not difficult, you just need to modify the rule regex
Thans so much for you help Jan. This will also help tremendously in another site I have - storelocator.no
I need identical rewrites tehre. This is sooo god :)
designers/(\d+)/?([^/]+)?/?
And then you change the $matches indexed of course, bid is now $matches[1], designer is $matches[2]
Good, next time we visit Scandinavia, I'll make sure to visit these sites with my wife!
:) Where are you from?
14:42
(Or not, if I want to have some money on our return journey...)
Belgium. Also good with fashion.
I knew some Finnish designers, but Norway is new for me
I thought it would be around that area - Jan is pretty "nordic"
what do you do for a living? Full tiem developer?
As a freelancer, yes. It used to be just a little bit WordPress, but the Stack Exchange got me hooked
Just like your original question was the first time I played with the rewrite engine
I'm no "hard core" programmer, it's beyond myskills to "play around" with things like that :)
I'm a front end developer and a usability geek.
with a pashion for fashion and photography.
OK, I updated my answer with a reference to this room, so others can follow the discussion too. Of course, you're free to accept it! (I assume your original answer is solved now too?)
yes, they both are :)
Thanks again for your help.
 
2 hours later…
17:23
@Jan Fabry: Am I supposed to be able to use $_GET['designer'] to retrieve designer slug?