- Custom Page and WordPress Templates the EASY way!
- Page Template vs WordPress Template
- What Happens When You Change The File Name of A Custom Template?
- Adding PHP Code To My Custom Templates?
- [do_shortcode] Button
- </wrap php> Button
- **Important NOTE**
- **Important Information About Naming Your Custom Template**
Custom Page and WordPress Templates the EASY way! #
When you create a Custom Template you can choose to either create a Page Template or a WordPress Template depending on your specific needs.
Page Template vs WordPress Template #
A Custom ” Page Template” is one that is selectable on a per-page basis. When this Template Type is selected your template file will be placed in your Child Theme’s “my-templates” folder where WordPress will recognize it as a Page Template. Then when you create or edit a Page you can select it in the “Page Attributes > Templates” drop-down menu in the area to the right of the WP Page Editor.
A Custom ” WordPress Template” is a custom version of a default template file found in WordPress. For example you could create a custom version of the single.php file making it so all single posts take on your custom version of that template. Note that these types of templates will be placed in your Child Theme’s root directory.
What Happens When You Change The File Name of A Custom Template? #
The file name of a Custom Template acts as it’s ID so when you change that name it does not rename the Template, but instead it creates a duplicate Custom Template with the new file name.
Adding PHP Code To My Custom Templates? #
When you add PHP code to your Custom Templates be sure to wrap it in <?php ?> tags.
[do_shortcode] Button #
To use shortcodes inside a Custom Template you need to wrap the [shortcode] in the do_shortcode() function. A quick and easy way to do this is to simply click on the [do_shortcode] button. That will automatically wrap any text it finds wrapped in square brackets with that do_shortcode() function.
Note, however, that there may be cases where square bracketed text is not shortcode text in which case you’d either need to manually add the do_shortcode() function to any actual shortcodes in that Template or just make sure to remove the do_shortcode() function code that is wrapped around any non-shortcode text.
</wrap php> Button #
Click this button to wrap your PHP code in opening and closing PHP tags. Note that this will wrap ALL content inside your Custom Template with PHP tags.
**Important NOTE** #
Be sure that each of your Custom Templates has a file name given to it. Failure to do this may result in the inability to Save your Custom Option settings.
**Important Information About Naming Your Custom Template** #
Be sure not to use “functions”, “front-page”, or “landing” as your template’s File Name as this may overwrite such default files found in the root of your Child Theme folder.