[wp-hackers] Rewrite Rules

Bill Erickson bill.erickson at gmail.com
Thu Feb 3 17:19:29 UTC 2011

I actually did something very similar to that on a recent project. I
was linking Posts to Pages using the Posts2Posts plugin. The client
then wanted to be able to drill down to specific categories, so I
created a custom rewrite endpoint. Going to
yoursite.com/pagename/articles/category-1 showed posts that were
linked to the current page and also in category 1.

Here's some additional resources that helped me:

John Beales - A little secret for URL manipulation in WordPress:
Stack Exchange - Custom URL Rewrites for Templates:

Bill Erickson
Wordpress Consultant

On Thu, Feb 3, 2011 at 11:11 AM, Michael Van Winkle
<mike at mikevanwinkle.com> wrote:
> Hey Ryan, check out this page in the Codex.
> http://codex.wordpress.org/Function_Reference/WP_Rewrite
> WordPress has two key filters for this:
> rewrite_rules_array (actually adds the rewrite rule)
> query_vars (adds rewrite rule/variable to the wp_query object)
> Cheers,
> Mike
> On Wed, Feb 2, 2011 at 6:11 PM, Ryan Bilesky <rbilesky at gmail.com> wrote:
>> I am looking to add rewrite rules for my plugin, my plugin will have a
>> shortcode embedded in a page, lets just say for example the url is
>> http://mysite.com/page I want a rewrite rule to get a url like this
>> http://mysite.com/page/something-here where something-here is a GET
>> parameter, it woul dbe like the url
>> http://mysite.com/page/?something=something-here, you get my point the page
>> will accept a GET parameter and I just want to rewrite the URL to make it
>> look better.  First off, my guess is yes, but just to make sure this is
>> possible right?  And the big question is how?  I haven't worked with rewrite
>> rules in wordpress before, now if I was to use .htaccess the rewrite rule
>> would look like this:
>> RewriteRule ^page/([^/]*)$ /page/?something=$1 [L]
>> How do I add this to the WordPress rewrite rules?
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> --
> Mike Van Winkle
> 708-289-3136
> mike at mikevanwinkle.com
> http://www.mikevanwinkle.com
> http://www.twitter.com/mpvanwinkle
> http://www.facebook.com/mpvanwinkle
> "All excellent things are as difficult as they are rare." -Spinoza
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list