How To Customize Wordpress Page Template
WordPress allows you to create custom layouts for all of your pages. These custom layouts are called templates.
For example, if you have a web design weblog, you can create a custom template that volition put the PHP logo on every page about PHP.
Some themes come with many templates already created, but creating your own is a very simple process.
In this tutorial, you will learn how to create a WordPress template that adds a PHP logo to all of your site PHP pages.
Pace #1: Locate your theme's existing pages
- Using a file manager or an FTP customer, locate your theme's directory on the server.
- Drill downwards to the /themes folder to run into your existing page templates.
- Locate the page.php file.
- Open it either with a text editor or, preferably, with a code editor.
Step #2: Insert proper name code
- Paste or type this code right before
get_header(); ?>
{codecitation}/* Template Proper name: My-New-Folio-Template */{/codecitation}
- Supervene upon
My-New-Page-Templatewith your ain template proper noun. You don't need the dashes. As well, notation that in the above example there's no opening PHP tag because it's upwards higher in the file. If your opening PHP tag is on the same line equally the get_header(); ?> , so your code needs to get correct after the opening tag (with a space between).
This code is what tells WordPress that this is a template file. We've used an existing page every bit a starter so we wouldn't need to write all the code from scratch.
You can do that if you are creating a very custom page. Without this code, WordPress will treat this PHP file as a default template if it'southward in the template's directory. This volition crusade you lot lots of bug. Be sure to have this code at the top of whatsoever page template.
Step #3: Save your new file
- Salve the file with a new proper noun and a .php extension. For example – MyNewTemplate.php.
- Put the file on the server at /wp-content/themes/yourtheme/MyNewTemplate.php (it'southward better non to have spaces in a file name).
You can proper noun this new file about anything you lot want, only there are some names that are reserved by WordPress for special purposes. I've included a list of those files in the notes at the end of the tutorial.
Pace #4: Add a custom logo
- Open the file.
- Paste the epitome code and styling right before the content.
- Add the following code to the page:
{codecitation}<div style="float: left; margin-right: 10px; margin-bottom: 2px;">
<img src="http://yourdomain.com/yourpix.jpg:>
</div>{/codecitation}
Step #5: Use your template to your pages
- Go to Pages > Add new.
- Choose My-New-Page-Template from the Page Attributes.
At present every page that has this template will have the PHP logo.
Reserved file names
Delight do not use the post-obit file names to name your custom folio templates:
- style.css -The main stylesheet. This must be included with your Theme, and it must incorporate the data header for your Theme.
- rtl.css – The rtl stylesheet. This will exist included automatically if the website's text management is right-to-left. This tin can be generated using the the RTLer plugin.
- alphabetize.php – The master template. If your Theme provides its own templates, alphabetize.php must be present.
- comments.php – The comments template.
- front-page.php – The front page template, information technology is only used if you use a static front end folio.
- dwelling house.php – The home folio template, which is the front page by default. If you use a static front folio this is the template for the folio with the latest posts.
- single.php – The single post template. Used when a single postal service is queried. For this and all other query templates, index.php is used if the query template is not present.
- single-.php – The unmarried post template used when a single mail from a custom post type is queried. For example, unmarried-books.php would be used for displaying single posts from the custom postal service blazon books. index.php is used if the query template for the custom mail type is non present.
- page.php – The folio template. Used when an private Page is queried.
- category.php – The category template. Used when a category is queried.
- tag.php – The tag template. Used when a tag is queried.
- taxonomy.php – The term template. Used when a term in a custom taxonomy is queried.
- writer.php – The writer template. Used when an author is queried.
- engagement.php – The engagement/fourth dimension template. Used when a date or time is queried. Year, month, mean solar day, hour, minute, second.
- archive.php – The annal template. Used when a category, author, or appointment is queried. Note that this template will be overridden by category.php, author.php, and date.php for their respective query types.
- search.php – The search results template. Used when a search is performed.
- attachment.php – Attachment template. Used when viewing a single zipper.
- prototype.php – Paradigm attachment template. Used when viewing a unmarried image zipper. If not present, attachment.php will be used.
- 404.php – The 404 Not Found template. Used when WordPress cannot observe a post or page that matches the query.
How To Customize Wordpress Page Template,
Source: https://ostraining.com/blog/wordpress/custom-page-template-wordpress/
Posted by: wrightititan79.blogspot.com

0 Response to "How To Customize Wordpress Page Template"
Post a Comment