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"] 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]
[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]
/*
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"] Have option to choose another template[/caption]
Wish succeed!
It's great!
ReplyDeleteمیگه: :چجوری باید تعداد برترین مطالب رو زیاد کنم ۳ تا فقط میاره !کد زیر رو در فایل lsidebar.php پیدا کنید و به جای ۱۵ هر عددی که خواستید بذارید$result = $wpdb->get_results( SELECTconemmt_count,ID,post_title FROM $wpdb->posts ORDER BY conemmt_countDESC LIMIT 0 , 15 );
ReplyDelete