How to rewrite / route / redirect to static php-file in wordpress theme?

I have a WordPress theme build from scratch ( not really, using -underscore starter theme... ).

I need to redirect users pointing to http://site.xxx/styletile to my kind-of-static file styletile.php in my theme directory.

What is easiest way?

Upvotes: 0

Views: 693

Answers (2)

Jeremy Benson
Jeremy Benson

Reputation: 1

Is your http://site.xxx/styletile page a regular WordPress Page?

If it is, I think the more "WordPress Way" would be to make styletile.php a page template and then set the template for that page in the CMS admin.

All you have to do is include a comment block at the top of the template

<?php
/*
 * Template Name: Style Tile
 *
*/

// The rest of your template

Then it will appear in the WordPress page editor on the right column in the Page Attributes widget in the drop-down as a page template. If you select it and update the page, WordPress will use your template instead of the default page template.

Depending on your setup this may or may not work, but if you are building a theme from scratch it might be useful to you.

Upvotes: 0

Donny Bridgen
Donny Bridgen

Reputation: 169

The easiest way would be to modify the .htaccess file and do a 302 Temporary redirect to that link

Redirect 302 http://site.xxx/styletile http://site.xxx/static.php

Alternatively you can achieve the same thing in PHP by doing:

header('Location: http://site.xxx/staticpage.php', true, 302);

Upvotes: 1

Related Questions