adsense

How to Create a Custom Template in WordPress





1. Open a blank document in a text editor and give the file a name. WordPress requires template files to be saved with a '.php' extension. Save it as 'custom_page.php' for now. The WordPress Codex contains a list of reserved filenames that cannot be used for custom template filenames. Those names are saved for predefined template files
2. Insert the following code into the page:
'Custom Page' is the name of the file, and WordPress calls it into the administration page panel by that name and defines it as a template. Change that to the desired template name.

3. Add
below the opening five lines of code. This calls the
information contained in the 'header.php' file.
4. Enter the HTML code to display the page information and style. The containers are defined in the style.css and can be copied from other template files. According to the WordPress Codex, the template files should be modeled after the 'index.php'. The following is basic HTML code used in the default WordPress theme, 'Twenty Ten':






The 'container' div defines the layout of the page and the 'content' div defines where WordPress calls the page content. The Loop and the index.php are called with the 'get_template_part();' tag. The Loop is the code that WordPress uses to display the PHP generated content, and 'index.php' adds the default design shown on the site's front page. Add additional IDs, classes and PHP between the opening and closing 'content' div. This information is dependent on the nature of the page; for instance, an 'Authors' page or 'Contact' page.
5. Insert
below the closing 'container' tag. This calls the 'footer.php,' which contains the closing
and
information for the page.
6. Save the file and upload it to the WordPress theme folder on the web server. The theme folder is located in '/wp-content/themes.'

Comments

0 Responses to "How to Create a Custom Template in WordPress"

Post a Comment

Popular Posts

About