Page slug for page template

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Page slug for page template

Roberto Sanchez
I want to set a page slug that applies to pages with a specific template.
For example, say I have a template named Case Study in case-study.php. When
I add a new Case Study page and assign to it the Case Study template, I
want the permalink of the page to now include case-study in the slug, like
this: http://example.com/case-study/q1-2014.


I would appreciate any tips on how to get this done. Thanks.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Page slug for page template

Nikola Nikolov
Not a complete answer on the original question, but I'd just suggest that
you use a Custom Post Type
<http://codex.wordpress.org/Function_Reference/register_post_type> for the
job. There you can set the rewrite slug option to "case-study" and that
will make any posts from that post type have the correct permalink.

Nikola


On Fri, Jun 20, 2014 at 5:05 PM, Roberto Sanchez <[hidden email]>
wrote:

> I want to set a page slug that applies to pages with a specific template.
> For example, say I have a template named Case Study in case-study.php. When
> I add a new Case Study page and assign to it the Case Study template, I
> want the permalink of the page to now include case-study in the slug, like
> this: http://example.com/case-study/q1-2014.
>
>
> I would appreciate any tips on how to get this done. Thanks.
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Page slug for page template

Eric Hendrix
Difficult situation since you're trying to get your slug to include a
directory followed by the post slug. I'm stumped.


On Fri, Jun 20, 2014 at 10:12 AM, Nikola Nikolov <[hidden email]>
wrote:

> Not a complete answer on the original question, but I'd just suggest that
> you use a Custom Post Type
> <http://codex.wordpress.org/Function_Reference/register_post_type> for the
> job. There you can set the rewrite slug option to "case-study" and that
> will make any posts from that post type have the correct permalink.
>
> Nikola
>
>
> On Fri, Jun 20, 2014 at 5:05 PM, Roberto Sanchez <
> [hidden email]>
> wrote:
>
> > I want to set a page slug that applies to pages with a specific template.
> > For example, say I have a template named Case Study in case-study.php.
> When
> > I add a new Case Study page and assign to it the Case Study template, I
> > want the permalink of the page to now include case-study in the slug,
> like
> > this: http://example.com/case-study/q1-2014.
> >
> >
> > I would appreciate any tips on how to get this done. Thanks.
> > _______________________________________________
> > wp-hackers mailing list
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



--


*Eric A. HendrixUSA, MSG(R)*[hidden email]
(910) 644-8940

*"Non Timebo Mala"*
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Page slug for page template

Nikola Nikolov
Alternatively have a parent page called Case Study? What you're trying to
do in the way you're trying to achieve it is if not impossible, then very
very difficult and there's no point in making your life that hard :)


On Fri, Jun 20, 2014 at 5:37 PM, Eric Hendrix <[hidden email]> wrote:

> Difficult situation since you're trying to get your slug to include a
> directory followed by the post slug. I'm stumped.
>
>
> On Fri, Jun 20, 2014 at 10:12 AM, Nikola Nikolov <[hidden email]>
> wrote:
>
> > Not a complete answer on the original question, but I'd just suggest that
> > you use a Custom Post Type
> > <http://codex.wordpress.org/Function_Reference/register_post_type> for
> the
> > job. There you can set the rewrite slug option to "case-study" and that
> > will make any posts from that post type have the correct permalink.
> >
> > Nikola
> >
> >
> > On Fri, Jun 20, 2014 at 5:05 PM, Roberto Sanchez <
> > [hidden email]>
> > wrote:
> >
> > > I want to set a page slug that applies to pages with a specific
> template.
> > > For example, say I have a template named Case Study in case-study.php.
> > When
> > > I add a new Case Study page and assign to it the Case Study template, I
> > > want the permalink of the page to now include case-study in the slug,
> > like
> > > this: http://example.com/case-study/q1-2014.
> > >
> > >
> > > I would appreciate any tips on how to get this done. Thanks.
> > > _______________________________________________
> > > wp-hackers mailing list
> > > [hidden email]
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> > _______________________________________________
> > wp-hackers mailing list
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
>
> --
>
>
> *Eric A. HendrixUSA, MSG(R)*[hidden email]
> (910) 644-8940
>
> *"Non Timebo Mala"*
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Page slug for page template

Eric Hendrix
Parent page is the correct term - thanks Nikola. Is there any way you'd
settle for a slug prefaced with your template name?


On Fri, Jun 20, 2014 at 10:48 AM, Nikola Nikolov <[hidden email]>
wrote:

> Alternatively have a parent page called Case Study? What you're trying to
> do in the way you're trying to achieve it is if not impossible, then very
> very difficult and there's no point in making your life that hard :)
>
>
> On Fri, Jun 20, 2014 at 5:37 PM, Eric Hendrix <[hidden email]> wrote:
>
> > Difficult situation since you're trying to get your slug to include a
> > directory followed by the post slug. I'm stumped.
> >
> >
> > On Fri, Jun 20, 2014 at 10:12 AM, Nikola Nikolov <[hidden email]>
> > wrote:
> >
> > > Not a complete answer on the original question, but I'd just suggest
> that
> > > you use a Custom Post Type
> > > <http://codex.wordpress.org/Function_Reference/register_post_type> for
> > the
> > > job. There you can set the rewrite slug option to "case-study" and that
> > > will make any posts from that post type have the correct permalink.
> > >
> > > Nikola
> > >
> > >
> > > On Fri, Jun 20, 2014 at 5:05 PM, Roberto Sanchez <
> > > [hidden email]>
> > > wrote:
> > >
> > > > I want to set a page slug that applies to pages with a specific
> > template.
> > > > For example, say I have a template named Case Study in
> case-study.php.
> > > When
> > > > I add a new Case Study page and assign to it the Case Study
> template, I
> > > > want the permalink of the page to now include case-study in the slug,
> > > like
> > > > this: http://example.com/case-study/q1-2014.
> > > >
> > > >
> > > > I would appreciate any tips on how to get this done. Thanks.
> > > > _______________________________________________
> > > > wp-hackers mailing list
> > > > [hidden email]
> > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > >
> > > _______________________________________________
> > > wp-hackers mailing list
> > > [hidden email]
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> >
> >
> >
> > --
> >
> >
> > *Eric A. HendrixUSA, MSG(R)*[hidden email]
> > (910) 644-8940
> >
> > *"Non Timebo Mala"*
> > _______________________________________________
> > wp-hackers mailing list
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



--


*Eric A. HendrixUSA, MSG(R)*[hidden email]
(910) 644-8940

*"Non Timebo Mala"*
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Page slug for page template

Paul Menard-3
Actually this is totally do able. You just attach a rewrite rule to a page
URL. I've done this before. The trick is to NOT have any child pages off
that parent. So for what you want you can have the default page template
associated with the /case-study/ page slug. If no query_var for the
'q1-2014, q3-1999, etc is not provided your template can just default to
some latest var and redirect.

The difficult page is that you are not going to be able to do this via the
template itself. You need to add the hooks to the theme functions.php so it
loads before the page template is called.

Let me dig up me code and provide a clean example.

P-



On Fri, Jun 20, 2014 at 10:58 AM, Eric Hendrix <[hidden email]> wrote:

> Parent page is the correct term - thanks Nikola. Is there any way you'd
> settle for a slug prefaced with your template name?
>
>
> On Fri, Jun 20, 2014 at 10:48 AM, Nikola Nikolov <[hidden email]>
> wrote:
>
> > Alternatively have a parent page called Case Study? What you're trying to
> > do in the way you're trying to achieve it is if not impossible, then very
> > very difficult and there's no point in making your life that hard :)
> >
> >
> > On Fri, Jun 20, 2014 at 5:37 PM, Eric Hendrix <[hidden email]>
> wrote:
> >
> > > Difficult situation since you're trying to get your slug to include a
> > > directory followed by the post slug. I'm stumped.
> > >
> > >
> > > On Fri, Jun 20, 2014 at 10:12 AM, Nikola Nikolov <
> [hidden email]>
> > > wrote:
> > >
> > > > Not a complete answer on the original question, but I'd just suggest
> > that
> > > > you use a Custom Post Type
> > > > <http://codex.wordpress.org/Function_Reference/register_post_type>
> for
> > > the
> > > > job. There you can set the rewrite slug option to "case-study" and
> that
> > > > will make any posts from that post type have the correct permalink.
> > > >
> > > > Nikola
> > > >
> > > >
> > > > On Fri, Jun 20, 2014 at 5:05 PM, Roberto Sanchez <
> > > > [hidden email]>
> > > > wrote:
> > > >
> > > > > I want to set a page slug that applies to pages with a specific
> > > template.
> > > > > For example, say I have a template named Case Study in
> > case-study.php.
> > > > When
> > > > > I add a new Case Study page and assign to it the Case Study
> > template, I
> > > > > want the permalink of the page to now include case-study in the
> slug,
> > > > like
> > > > > this: http://example.com/case-study/q1-2014.
> > > > >
> > > > >
> > > > > I would appreciate any tips on how to get this done. Thanks.
> > > > > _______________________________________________
> > > > > wp-hackers mailing list
> > > > > [hidden email]
> > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > > >
> > > > _______________________________________________
> > > > wp-hackers mailing list
> > > > [hidden email]
> > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > >
> > >
> > >
> > >
> > > --
> > >
> > >
> > > *Eric A. HendrixUSA, MSG(R)*[hidden email]
> > > (910) 644-8940
> > >
> > > *"Non Timebo Mala"*
> > > _______________________________________________
> > > wp-hackers mailing list
> > > [hidden email]
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> > _______________________________________________
> > wp-hackers mailing list
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
>
> --
>
>
> *Eric A. HendrixUSA, MSG(R)*[hidden email]
> (910) 644-8940
>
> *"Non Timebo Mala"*
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Page slug for page template

Roberto Sanchez
In reply to this post by Roberto Sanchez
Hi all,

Thank you for your suggestions. I decided to follow Nikola's advice
and just use a custom post type instead. It was the easiest option
that worked for me.

Thanks again!
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers