Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

After WP upgrade from 3.2.1 to 3.4.1 I faced the problem that rules are not applied same way.

I have the following rule:

(questions-answers)/([mind|nutrition|fitness|beauty]*)[/page/]*(\d*)$

In WP 3.2.1 URL /questions-answers/mid/page/2 matches rule mentioned above, but in 3.4.1 this URL matches different rule: (.?.+?)/page/?([0-9]{1,})/?$.

Any ideas what is wrong and how can I solve the problem?

share|improve this question
add comment

1 Answer

I recognize that rule. It's the unusual rule I wrote to deal with the permalink uncertainty issue. :)

First, you'll only get that weird rule if you have your custom permalinks set to start with a non-numeric value. Like, if you have your custom permalink string as just %postname% instead of something like %year%/%postname%.

Next, the special-case rule you're finding isn't added to the top of the list. So if you have your rule being added, then your rule is more specific, and you should be adding it to the top of the rewrite stack so that it gets checked first. You can set the third parameter to add_rewrite_rule to 'top' to do that.

That should solve the issue, really. If it doesn't, well, you'll have to post code so people can see what the problem is.

share|improve this answer
    
Indeed, I use custom permalink: /%category%/%postname%.html (customer requirement) and my special rule is on top (checked with Rewrite analyzer). What part of the code could be useful to see where the pronlem is? –  Uldis Oct 1 '12 at 9:19
    
I even updated regexp to (questions-answers)/((mind|nutrition|fitness|beauty)/)?(page/([0-9]+))? so now Rewrite analyzer shows that all parts are recognized correctly. Unfortunately this redirects me to category view. –  Uldis Oct 1 '12 at 9:37
    
If your special rule is on the top of the list, and you're getting something different, then your rule is wrong and not matching your URL. See, the matches happen top to bottom. So if you end up matching a different rule, then that means your rule is wrong somehow. –  Otto Oct 1 '12 at 9:48
    
How can I output all rewrite rules in order they are apllied to URL? –  Uldis Oct 1 '12 at 12:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.