Skip to main content

Create Wordpress page template

When creating a new page in Wordpress, we usually have a choice for the page template. It's call Default template. However, we sometimes need to make a new page with a new appearance. Then another page template is needed. Instead of downloading a shared page template from internet, we can create a new page template by below instructions.




[caption id="attachment_504" align="alignnone" width="289"]Wordpress page template 1 Only have default template[/caption]

  • Create template file: 

    • Go to your website file manager and open your current theme directory: /wp-content/themes/your_current_theme_name/

    • Create a new file like your_new_template.php contains below codes with Your new template is your new template name:




[html]<?php
/*
Template Name: Your new template
*/
?>[/html]

  • Before building contents for new template, you should know the template tags. They will be used to display your template contents dynamically. Some common template tags are:

    • get_header():  display header part by including header.php file from your current theme directory;

    • the_content(): display the contents of current page;

    • get_sidebar(): display siderbar part by including sidebar.php file from your current theme directory;

    • get_footer(): display footer part by including footer.php file from your current theme directory;

    • And more tags at Wordpress Codex.



  • Coding template contents: using the template tags, we can simply build the template contents. We have an example for full width layout template here.


[html]<php get_header(); ?>
<div id="content" class="content">
<div class="post">
<div class="entrytext">
<?php the_content(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>[/html]


That's all. After creating new template, you can now use it for new appearance page.



[caption id="attachment_505" align="alignnone" width="288"]Wordpress page template 2 Have option to choose another template[/caption]


Wish succeed!

Comments

  1. می‌گه: :چجوری باید تعداد برترین مطالب رو زیاد کنم ۳ تا فقط میاره !کد زیر رو در فایل lsidebar.php پیدا کنید و به جای ۱۵ هر عددی که خواستید بذارید$result = $wpdb->get_results( SELECTconemmt_count,ID,post_title FROM $wpdb->posts ORDER BY conemmt_countDESC LIMIT 0 , 15 );

    ReplyDelete

Post a Comment

Popular posts from this blog

Integrate blogspot blogger blog with Dot TK free domain

Blogspot or Blogger is a blog service from Google. This service provides us many functions to make a small website as creating a blog, posting, commenting, . . . But there is a thing which might cause you dissatisfy. That's the blog address is too long, like http://www.your-tips-tricks.blogspot.com . If you own a short Dot TK domain , then your problems will be solved.

Download Picasa Web Albums photos

We've known that Google Picasa Web Albums is among of best online photo services. It provides our many useful services as 1GB photo storage, upload and edit photos, embed and share albums , integrate with Google+, etc. However, many people usually feel inconvenient because they don't see anything about download albums on it.