[wp-hackers] Rewrite rules after unknown url structure

William Satterwhite whsatterwhite at gmail.com
Tue Oct 22 16:07:43 UTC 2013


Ah I see. I've done something similar, but I was actually querying for a
custom post type, but the requested URL utilized the existing page URL
structure. And FWIW I was using a custom query_var as well.

This being the live example that I'm referring to:
http://michiganfireworks.com/by-date/2013-11-01/

The ISO date is the custom query var, but the by-date portion is using your
normal page URL structure.

I agree with John; look in to endpoints.


On Tue, Oct 22, 2013 at 11:58 AM, Jesse Friedman <me at jes.se.com> wrote:

> Hey Hunter
>
> The SEM landing pages don't really exist. Basically if that parameter is
> set to True it just strips out the nav, sidebar, and footer and replaces it
> with other markup. So every post, page, cpt can potentially be an SEM
> landing page.
>
> Jesse
>
>
> On Tue, Oct 22, 2013 at 11:54 AM, William Satterwhite <
> whsatterwhite at gmail.com> wrote:
>
> > Are your SEM landing pages actual pages or another custom post type? If
> > they're another custom post type you could add an additional parameter
> > specifying the post type in your add_rewrite_rules function.
> >
> >  $aNewRules = array('sample-page/([^/]+)/?$' =>
> > 'index.php?*post_type=sem_pages*&pagename=sample-page&sid=$matches[1]');
> >
> >
> > On Tue, Oct 22, 2013 at 11:49 AM, Jesse Friedman <me at jes.se.com> wrote:
> >
> > > Hi Everyone
> > >
> > > Thanks in advance for any help.
> > >
> > > We have a plugin that turns all of our pages and CPT's into SEM landing
> > > pages simply by appending ?sem=true to the end of the url.  Google has
> > > recently decided to start declining our campaigns because of this
> > > parameter.
> > >
> > > So right now I have
> > > domain.com/coverage/vehicle/?sem=true
> > >
> > > I need it to be
> > > domain.com/coverage/vehicle/sem
> > >
> > > I have the following code, which works well to a point.
> > >
> > > function add_query_vars($aVars) {
> > >     $aVars[] = "sid";    // represents the name of the product category
> > as
> > > shown in the URL
> > >     return $aVars;
> > > }
> > >
> > > add_filter('query_vars', 'add_query_vars');
> > >
> > > function add_rewrite_rules($aRules) {
> > >     $aNewRules = array('sample-page/([^/]+)/?$' =>
> > > 'index.php?pagename=sample-page&sid=$matches[1]');
> > >     $aRules = $aNewRules + $aRules;
> > >     return $aRules;
> > > }
> > >
> > > add_filter('rewrite_rules_array', 'add_rewrite_rules');
> > >
> > > The problem is that, this code assumes this parameter is only going to
> be
> > > used on pages where pagename=='sample-page'
> > >
> > > I need to be able to get the var on any page, post, cpt, etc...
> > >
> > > I'm find with doing
> > >
> > > domain.com/sem/sample-page
> > >
> > >
> > > Can someone point me in the right direction?
> > >
> > >
> > > --
> > > thanks
> > >
> > > *jesse friedman*
> > > jes.se.com *
> > > *
> > > Book: Web Designers Guide to WordPress -
> > > http://wdgwp.com/onamazon<http://wdgwp.com/onamazon>
> > > Twitter: @professor <http://twitter.com/professor>
> > > Facebook: Like<
> > > https://www.facebook.com/pages/Jesse-Friedman/204793299545174>
> > > _______________________________________________
> > > 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
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
>
> --
> thanks
>
> *jesse friedman*
> jes.se.com *
> *
> Book: Web Designers Guide to WordPress -
> http://wdgwp.com/onamazon<http://wdgwp.com/onamazon>
> Twitter: @professor <http://twitter.com/professor>
> Facebook: Like<
> https://www.facebook.com/pages/Jesse-Friedman/204793299545174>
> _______________________________________________
> 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


More information about the wp-hackers mailing list