1. สร้าง Template ใหม่ขึ้นมา โดย Copy ไฟล์ page.php เพิ่มโค้ดลงไป เซฟชื่อใหม่(ของผมเซฟเป็น one-column-template.php) ไฟล์จะเป็นดังนี้
<?php
/*
Template Name: One column template
*/
get_header(); ?>
<!--content-->
<div id="content">
<div id="left-col">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="post-head">
<h1><?php the_title(); ?></h1>
</div><!--post-heading end-->
<div class="post-entry">
<?php the_content(); ?>
<div class="clear"></div>
<?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'thememagic' ), 'after' => '' ) ); ?>
</div><!--post-entry end-->
<?php if(of_get_option('comment_page') != "off") { ?>
<?php comments_template( '', true ); ?>
<?php } ?>
<?php endwhile; ?>
</div> <!--left-col end-->
<?php //get_sidebar(); ?>
</div> <!--content end-->
</div>
<!--wrapper end-->
<?php get_footer(); ?>
- ที่เพิ่มขึ้นมาคือส่วนหัว ---> Template Name: ชื่อเทมเพลท เพื่อบอกให้รู้ว่านี่เป็นเทมเพลทใหม่ ตั้งชื่อตามต้องการ ในที่นี้ผมตั้งเป็น One column template
- <?php //get_sidebar(); ?> ---> เอา sidebar ออก โดยผมเอาออกโดยการใส่ //
2. ไปที่ Appearance > Theme Options > Style Settings แล้วเพิ่มโค้ดลงไป หรือจะไปแก้ใน style.css ก็ได้
body.page-template-one-column-template-php #content {
background: none; /* ลบเส้นแนวตั้ง */
}
body.page-template-one-column-template-php #content #left-col {
width: 964px; /* ขยายให้เต็มพื้นที่ */
padding: 20px 11px 20px 10px;
margin: 0 auto;
z-index: 1;
}
body.page-template-one-column-template-php .post-entry {
width: 964px; /* ขยายให้เต็มพื้นที่ */
float:left;
padding-bottom: 10px;
padding-top: 10px;
}
ไป edit page ที่ต้องการ เลือก Template เป็น One column template(หรือชื่อที่ท่านตั้งไว้) ก็จะได้เพจเต็มพื้นที่แบบไม่มี sidebar ครับ ผมลองดูแล้วได้นะ