[wp-hackers] Custom Re-write Rules

William Satterwhite whsatterwhite at gmail.com
Fri Jan 25 22:42:06 UTC 2013


Ok, I narrowed it down and fixed it. Otto and Drew thank you for the help
and also Drew thanks for directing me to use add_rewrite_tag versus
appending the custom variable to the query_var array. I'm sure both will
give you the desired results, but I'm in favor of add_rewrite_tag for best
practices.

The issue was a type in the regular expression, which I realized after
installing and using Monkeyman Rewrite Analyzer by Jan Fabry. Kudos to Jan
for a great plugin!

Best,
Hunter

On Fri, Jan 25, 2013 at 5:31 PM, William Satterwhite <
whsatterwhite at gmail.com> wrote:

> Thanks Drew! I did just that and am still not seeing the query_var
> registered when I run print_r( $wp_query);
>
> This is the revised bit of code that I'm using for the custom rewrite:
> http://pastebin.com/sg5Xz82R
>
>
> On Fri, Jan 25, 2013 at 4:43 PM, Drew <xoodrew at gmail.com> wrote:
>
>> >
>> > Something I just noticed is when run print_r( $wp_query); on what
>> should be
>> > the custom rewrite page I don't even see wpem_event_date set in the
>> > query_vars array. It is actually set as the attachment query_var:
>>
>>
>> I seem to recall you need to register new query_vars with
>> add_rewrite_tag().
>>
>> Would explain why it's not showing up on the other end. See:
>> http://codex.wordpress.org/Rewrite_API/add_rewrite_tag
>>
>>
>>
>> On Fri, Jan 25, 2013 at 1:54 PM, William Satterwhite <
>> whsatterwhite at gmail.com> wrote:
>>
>> > Something I just noticed is when run print_r( $wp_query); on what
>> should be
>> > the custom rewrite page I don't even see wpem_event_date set in the
>> > query_vars array. It is actually set as the attachment query_var:
>> >
>> > object(WP_Query)#781 (44) { ["query"]=> array(1) { ["attachment"]=>
>> > string(10) "2013-01-25" } ["query_vars"]=> array(56) { ["attachment"]=>
>> > string(10) "2013-01-25"
>> >
>> > On Fri, Jan 25, 2013 at 3:33 PM, William Satterwhite <
>> > whsatterwhite at gmail.com> wrote:
>> >
>> > > Thanks for taking a look at it Otto. I do in fact have a page named
>> > > by-date and I also have WP_DEBUG set to true.
>> > >
>> > >
>> > > On Fri, Jan 25, 2013 at 3:31 PM, Otto <otto at ottodestruct.com> wrote:
>> > >
>> > >> Nothing wrong with that code.
>> > >>
>> > >> Do you actually have a Page with a slug of "by-date"?
>> > >>
>> > >> -Otto
>> > >>
>> > >>
>> > >> On Fri, Jan 25, 2013 at 1:27 PM, William Satterwhite
>> > >> <whsatterwhite at gmail.com> wrote:
>> > >> > I've been working on getting custom re-write rules working in
>> > WordPress
>> > >> and
>> > >> > I've been through the Codex as well as countless tutorials that
>> show
>> > the
>> > >> > various ways that rewrite rules can be implemented. Now, I'd like
>> to
>> > >> think
>> > >> > that I'm doing it right, but every time I visit a URL for the
>> custom
>> > >> > re-write it 404's on me. I know the re-write is registered within
>> > >> > WordPress, because I can check rewrite_rules in wp_options and see
>> it
>> > >> > specified.
>> > >> >
>> > >> > The rule itself is to allow me to point to a page using an ISO
>> > formatted
>> > >> > date as the query_var e.g. http://site.com/by-date/YYYY-mm-dd or
>> > >> > http://site.com/by-date/2013-02-01. by-date being the static page
>> > that
>> > >> I
>> > >> > want to included in the custom re-rewrite. If anyone could provide
>> > some
>> > >> > insight on what I may be doing wrong or missing then please let me
>> > know.
>> > >> >
>> > >> > Here's the pastebin of what I've written. <
>> > http://pastebin.com/NCESJF0P
>> > >> >
>> > >> >
>> > >> > Best,
>> > >> > --
>> > >> > Hunter Satterwhite
>> > >> > http://linkedin.com/in/hsatterwhite
>> > >> > (252) 762-5177
>> > >> > _______________________________________________
>> > >> > wp-hackers mailing list
>> > >> > wp-hackers at lists.automattic.com
>> > >> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>> > >> _______________________________________________
>> > >> wp-hackers mailing list
>> > >> wp-hackers at lists.automattic.com
>> > >> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> > >>
>> > >
>> > >
>> > >
>> > > --
>> > > Hunter Satterwhite
>> > > http://linkedin.com/in/hsatterwhite
>> > > (252) 762-5177
>> > >
>> >
>> >
>> >
>> > --
>> > Hunter Satterwhite
>> > http://linkedin.com/in/hsatterwhite
>> > (252) 762-5177
>> > _______________________________________________
>> > wp-hackers mailing list
>> > wp-hackers at lists.automattic.com
>> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>> >
>>
>>
>>
>> --
>> -- I've kinda got a thing for WordPress > http://www.drewapicture.com
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> Hunter Satterwhite
> http://linkedin.com/in/hsatterwhite
> (252) 762-5177
>



-- 
Hunter Satterwhite
http://linkedin.com/in/hsatterwhite
(252) 762-5177


More information about the wp-hackers mailing list