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.

I'm working on a project which involves filtering some customs posts on the front-end. I managed to create the permalinks including a custom field, but it seems that the rewrite rule matches some unwanted pages, making them not display-able on the frontend.

The code I use for rewriting :

$wp_rewrite->add_rewrite_tag('%competition%', '([^/]+)', 'competition=');
$wp_rewrite->add_rewrite_tag('%prize_category%', '([^/]+)', 'prize_category=');
$wp_rewrite->add_permastruct('competition', '/au/%prize_category%/%competition%/', false);

The problem is the following. It does what it should do for this url:

http://example.com/au/win-a-holiday/win-a-long-weekend-at-the-rees-hotel-queenstown/

But it also matches this one:

http://example.com/au/win-a-holiday/

Is there anyway I could force the second parameter %competition% to be mandatory? So the rule will apply only for URLs like:

http://example.com/au/param1/param2 not for domain.com/au/param1/ ?

Thanks, George

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.