WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a page called Catalog and also a template called page-catalog.php. The url looks like this now: sitename.com/catalog

So far so good, however i use some custom php stuff to list products from another database. So when i click on a brand in this page, i want to use an url like this: sitename.com/catalog/brands/brandname

But obviously because the data is not coming from Wordpress, it gives me 404. Is it possible to use the same page-catalog.php file if the url has more parts?

I could use an url like this: sitename.com/catalog/?brand=brandname But this solution is not so sep friendly.

share|improve this question
Your question really isn't about disabling the 404 page, as it is about how to combine external DB data with WordPress data. – Chip Bennett May 24 '12 at 16:07
up vote 0 down vote accepted

You could use a WordPress rewrite (as opposed to mod-rewrite) to solve the issue.

function createRewriteRules( $rules ){
    $newrules = null;
    $newrules = array();
    $newrules["catalog/?$"] = "index.php?page=xx";
    $rules = $newrules + $rules;
    return $rules;

add_action('rewrite_rules_array', 'createRewriteRules');

You'll need to flush the rules:


Your page-catalog.php file could then sniff the original url and do some processing as required.

share|improve this answer
Thanks, i just tried it, but it's not working. .com/catalog loads up my index.php, .com/catalog/anything gives me 404.php – passatgt May 24 '12 at 17:14
Did you flush the rules? (A quick way is in WP Admin, change your permalink structure to something different, save, and then change it back and save). – Roscius May 24 '12 at 18:19
Also, try with the function in a plugin as opposed to functions.php – Roscius May 24 '12 at 18:20
Yes, that was the problem, thanks! Maybe i can mess with the add_action location, like add_action=init to make this work from the functions.php – passatgt May 26 '12 at 8:27
It's most likely that functions.php doesn't work because it loads fairly late in the bootstrap process, loading the rewrite rules too late may have other unintended consquences - they're used to determine a bunch of things, most importantly what template to load. – Roscius May 26 '12 at 17:31

Your Answer


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.