WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] How to assign a Page Template to certain URL Patterns?

[Resolved] How to assign a Page Template to certain URL Patterns?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    @bcworkz

    Sorry for the slow reply.

    Use add_rewrite_rule() so that when “snippet” is matched in the URL, your template is requested. You will want to pass the prior path element as an URL parameter so your template has the parent slug to use.

    I had already found an alternative but that may do the trick. I’ll look into it. For now I’ll mark this as closed.

    He Call_Me_Matthew, I’m interested in what your alternative was for this.
    Care to share?

    Hey Matt. I ended up using a plugin called Pods Framework with an extension for it called Pods Pages.

    Basically, You use Pods to create custom post types, and Pods Pages to create template files for those custom post types. Pods Pages will let you specify the url pattern to attach your template to.

    Then in my template code, I used $post->post_name to get the slug of the current page, and created a loop that outputs the custom post type with that matching slug.

    You can find plenty of tutorials/documentation on how it works on their site or by searching Google. I finished this project a year ago so I couldn’t tell you exactly what I did, but hope this helps!

    Got it. Thanks matt.
    Im doing something similar to your original request but dont want to have to create all the duplicate pages down the line. I think i have it sorted out to wildcard match the permalink and the parent page will drive which template header to grab with an action hook.

    This may be worth a read:

    Rewrite endpoints API

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] How to assign a Page Template to certain URL Patterns?’ is closed to new replies.
Skip to toolbar