ใครเก่ง php ช่วยผมทีครับ

เริ่มโดย paiyong, 07 มิถุนายน 2009, 12:56:46

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

paiyong

 :-* คือตอนนี้ผมทำ web โดยใช้ wp แต่อยากจะแก้ไฟล์
page.php คับ โดยต้องการให้บาง page แสดง sidebar ส่วนบาง page ไม่ต้องแสดง sidebar โดยเอา ชื่อของpage นั้นเป็นตัวกำหนดว่าให้ show side bar หรือไม่นะครับ

ตัวอย่าง
- ต้องการให้ page ชื่อ tmp1 แสดง sidebar ส่วน tmp2 ไม่ต้องแสดง sidebar

*ลองพยายามแก้โดยใช้ if else แล้วเอา function the_title(); มาใช้ใน reg.exp. แต่มันไม่เวิคอ่ะคับ
**ข้างล่างป็นอันที่ผมพยายามแก้แต่ไม่สำร็จคับ

===================================================
<?php get_header(); ?>

   <div id="content2">

      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <div class="post" id="post-<?php the_ID(); ?>">
      <h2><?php the_title(); ?></h2>
         <div class="entry">
            <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>

            <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

         </div>
      </div>
      <?php endwhile; endif; ?>
   <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
   </div>

<!-----ลองแก้ -->
<?php
$page1 =  the_title();
if ($page1 == "tmp1" ) {
get_sidebar();
}
?>
<!--จบ -->


<?php get_footer();?>
=====================================================

qwert001

ลองเปลี่ยน the_title()  เป็น get_the_title() ดูครับ
งดรับงานถาวรครับ อยากทำอย่างอื่นบ้าง... 
[direct=http://www.thaihomelist.com/post.php]ลงประกาศบ้าน ฟรี[/direct] [direct=http://www.thaihomeads.com]ขายบ้าน เช่าบ้าน[/direct][direct=http://travel.thaihomelist.com/]จองโรงแรม รีสอร์ท[/direct]
[direct=http://travel.thaihomelist.com/hotel-th-161923-เซ็นทาราแกรนด์มิราจ.html]เซ็นทารา แกรนด์ มิราจ บีช[/direct][direct=http://www.thaipropertyfund.com]กองทุนรวมอสังหาฯ[/direct]