สอบถาม wp ทำยังไงให้หน้า index แสดงโพสใหม่ฉพาะบาง category

เริ่มโดย pigdoll, 03 พฤษภาคม 2012, 15:34:14

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

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

pigdoll

สอบถาม wp ทำยังไงให้หน้า index แสดงโพสใหม่ฉพาะบาง category ครับ

ต้องแก้ code อย่างไร  :wanwan017:

emukidz

ใช้ query แยก Cat ที่ไม่เอาออกครับ ครับ เช่น

<?php
if ( is_home() ) {
   query_posts( 'cat=-1,-2,-3' ); //ไม่แสดง cat ID = 1,2,3
}
?>
[direct=http://www.barekadin.com]เสื้อผ้าแฟชั่นราคาถูก[/direct]
[direct=http://www.tshirtstreetwear.com]เสื้อยืดแฟชั่น[/direct]

pigdoll

อ้างถึงจาก: emukidz ใน 03 พฤษภาคม 2012, 17:09:36
ใช้ query แยก Cat ที่ไม่เอาออกครับ ครับ เช่น

<?php
if ( is_home() ) {
   query_posts( 'cat=-1,-2,-3' ); //ไม่แสดง cat ID = 1,2,3
}
?>

ไม่ทราบว่าใส่ตรงไหนอะครับ


proexcellant

อยากให้โพสของหมวดหมู่นั้นๆ แสดงเฉพาะหน้าได้มั้ยครับ

KenjiroAPI

อ้างถึง
<?php
$featuredPosts = new WP_Query();
$featuredPosts->query('showposts=5&cat=3');
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<div class="meta">
By <?php the_author() ?>
</div>
<div class="storycontent">
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>

เปลี่ยนตรงที่ผมเน้นไว้นะครับ showposts คือจำนวนโพสต์ที่ต้องการให้โชว์ครับ ส่วน cat คือหมายเลขของหมวดหมู่ที่ต้องการให้แสดงครับ
อ้างอิงจาก: http://bavotasan.com/2009/using-wp_query-to-fetch-posts-in-wordpress/

proexcellant

อ้างถึงจาก: KenjiroAPI ใน 04 พฤษภาคม 2012, 02:14:31
อ้างถึง
<?php
$featuredPosts = new WP_Query();
$featuredPosts->query('showposts=5&cat=3');
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<div class="meta">
By <?php the_author() ?>
</div>
<div class="storycontent">
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>

เปลี่ยนตรงที่ผมเน้นไว้นะครับ showposts คือจำนวนโพสต์ที่ต้องการให้โชว์ครับ ส่วน cat คือหมายเลขของหมวดหมู่ที่ต้องการให้แสดงครับ
อ้างอิงจาก: http://bavotasan.com/2009/using-wp_query-to-fetch-posts-in-wordpress/

อันที่กล่าวมาข้างต้นนี่คือวิธีทำอะไรหรอครับ

KenjiroAPI

อ้างถึงจาก: proexcellant ใน 04 พฤษภาคม 2012, 02:17:25
อ้างถึงจาก: KenjiroAPI ใน 04 พฤษภาคม 2012, 02:14:31
อ้างถึง
<?php
$featuredPosts = new WP_Query();
$featuredPosts->query('showposts=5&cat=3');
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<div class="meta">
By <?php the_author() ?>
</div>
<div class="storycontent">
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>

เปลี่ยนตรงที่ผมเน้นไว้นะครับ showposts คือจำนวนโพสต์ที่ต้องการให้โชว์ครับ ส่วน cat คือหมายเลขของหมวดหมู่ที่ต้องการให้แสดงครับ
อ้างอิงจาก: http://bavotasan.com/2009/using-wp_query-to-fetch-posts-in-wordpress/

อันที่กล่าวมาข้างต้นนี่คือวิธีทำอะไรหรอครับ

อ้าวแล้วพี่ท่านถามอะไรละครับ  :P