0

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.

1
  • 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
    Commented Aug 1, 2012 at 13:28

1 Answer 1

2

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

3
  • 2
    +1 and don't forget abour add_query_arg().
    – kaiser
    Commented Jul 31, 2012 at 18:49
  • cool, didn't know about this one, thanks!
    – Jan Beck
    Commented Jul 31, 2012 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
    Commented Aug 1, 2012 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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