Support » Themes and Templates » Template file accessible with vanity URL

  • How do you make a template file accessible via a vanity URL ‘without’ assigning it to a page in the WP admin?

    For example say I have a file blah.php, can I programmatically make that file accessible via

    Can this be done via functions.php?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer



    You could create a directory /blah and put an index.php file in there. Then you can link to

    I think you can do like that with templates.
    Add this at the begin of your page-blah.php
    Template Name: Blah
    And you have a new attribute on the right of your edit page !

    mathis@Tambour the solution I wanted was to do it without the Admin interface (new/edit page)

    keesiemeijer that could work…

    I ended up not needing it, however for future it would be good to be able to do such a thing via a declaration in functions.php or similar.

    Moderator keesiemeijer



    You can do it with this in your theme’s functions.php with a template called blah.php in your current theme folder:

    It adds the rewrite rule and query var for /blah and uses the template file blah.php if you are visiting

    Be aware that if you publish a page or post with slug ‘blah’ the template blah.php will be used.

    Nice, will check that out.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Template file accessible with vanity URL’ is closed to new replies.