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've done a bit of googling, searching on forums, etc, and can't find a good answer. Here is what I'm doing: I need to pass a variable in the url to the page and have a rewrite to make it pretty. So, "mysite.com/ninny/hello-world" is really "mysite.com/ninny.php?c=hello-world". This is currently in action on a non-wordpress site using .htaccess rewrites and php.

I'm trying to create a plugin to do this. Have a file with all the code that is in the "ninny.php" file in the plugin and have it appear on the front-end, like a page, with get_header(), and other functions working, to visitors when they visit mysite.com/ninny or "mysite.com/ninny/hello-world". A plugin is ideal, although a page template could suffice.

The issue I'm having is that if you rewrite the url for a page that is in the plugin it doesn't load all the Wordpress functions - so you wind up with all kind of fun errors. I don't want to call wp-load within the site like that.

What can I do so that the plugin is creating a "page" (not a real entry-in-the-database page), that doesn't go around wordpress like mine currently does.

Is there any way to do a rewrite and have it loading the wordpress functions? Where should I be looking here?

Thank you in advance for anything that points me in the right direction. If this all doesn't make any sense, feel free to ask questions.

share|improve this question
I didn't explain it very well, so here's some further clarification: I need to be able have a page, it doesn't have to even appear as a page in the admin (although it is fine if it does). The content of this page will be modified based on a variable set in the URL, "?c=". The reason for a rewrite is that I don't want the url to show it as a variable, but rather as a "pretty" link. So if "c" equals "ninnny" then it would NOT be mysite.com/whateverpageCisappendedto?c=ninny , but rather, mysite.com/whateverpageCisappendedto/ninny/ – Tim Aug 1 '12 at 13:28

I think you should take a step back and clarify what you are actually trying to do. Usually with WordPress there is no need to throw around with crazy redirects, virtual pages and file includes. Although you can do all these things (mentioning WP_Rewrite).

When all you want is passing parameters to a page all you have to do is add them to the normal permalink of your page: mysite.com/ninny/hello-world?c=hello-world

share|improve this answer
+1 and don't forget abour add_query_arg()‌​. – kaiser Jul 31 '12 at 18:49
cool, didn't know about this one, thanks! – Jan Beck Jul 31 '12 at 19:01
I just added a comment above to further explain my post. A much more simple explanation, I think. Let me know if you need further clarification! I think I may have been barking up the wrong tree as far as methods are concerned. – Tim Aug 1 '12 at 13:32

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.