wordpress อยากได้ url xxx.com หน้าแรกคัดเฉพาะ content ตาม category

เริ่มโดย ubee158, 22 กันยายน 2009, 17:18:58

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

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

ubee158

หน้าแรกเดิมเป็นแบบนี้ครับ
http://xxx.com                      <<เดิม ๆ
content1 - category 1
content2 - category 3
content3 - category 5
content4 - category 9
content5 - category 2

ปรับใหม่โดย redirect url หรือแก้แบบ frontpage แล้วได้ url เป็นแบบนี้
http://xxx.com/category1          << นู๋ไม่เอา
content1 - category 1
content6 - category 1
content8 - category 1
content13 - category 1
content20 - category 1

แต่ผมอยากให้เปิดมาหน้าแรกได้แบบนี้ครับ
http://xxx.com                        << นู๋อยากได้
content1 - category 1
content6 - category 1
content8 - category 1
content13 - category 1
content20 - category 1


:-Xไม่ทราบว่าใครมี วิธีแก้ หรือ plugins ไหมครับ วอนผู้ใจบุญช่วยสงเคราะห์ทีครับ.

แมวมีเจ้าของ

#1
ไม่รู้ว่าผมเข้าใจถูกป่าว แบบว่าแสดงบทความแยกตาม category
แต่ถ้าใช่ก้เอาไปปรับใช้ตามความเหมาะสมได้เลยครับ อิอิ

อ้างถึง
<?php $recent = new WP_Query("cat=7&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li></ul>

cat=7 คือ หมายเลข หรือลำดับของ category ตัวอย่างคือ ลำดับที่ 7
แนะนำว่าให้มีบทความของแต่ละ category ก่อนนะ เวลาตั้งค่าจะได้รู้ว่าอันไหนของอันไหน
(เพราะผมยังใช้วิธีสุ่มและจดจำบทความเอง แบบว่าไม่รู้เทคนิควิธีการดูเลขลำดับมันเลย)

showposts=3 คือ จำนวนบทความที่ต้องการแสดง ตัวอย่างคือ แสดง 3 บทความ

ปล. ถ้าเข้าใจผิด ไปคนละเรื่อง ก้อย่าถือสา แบบว่า มือใหม่หัดทำ เหมือนกัน อิอิ ร้อนวิชา เอิีกส์

แมวมีเจ้าของ

#2
อ้างถึงจาก: เจ้าชายกระหายเลือด ใน 22 กันยายน 2009, 23:46:25
อ้างถึง
<?php $recent = new WP_Query("cat=7&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li></ul>

ข้างบนนี้สำหรับแสดงลิงค์บทความอย่างเดียว แต่ถ้าอยากให้แสดงเนื้อหาด้วยก็เพิ่มนี่เข้าไป

<?php the_content('Read more...'); ?>

เป็น

อ้างถึง
<?php $recent = new WP_Query("cat=7&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php the_content('Read more...'); ?></li></ul>

เพิ่มเติมที่
http://codex.wordpress.org/The_Loop

ubee158

 :-[ ไม่ทราบว่าเอา code ไปวางใส่ไว้ทีไฟล์ไหนหรือครับ ผมเอาไปใส่ที่ index.php แล้วมัน error น่ะครับ

แมวมีเจ้าของ


วางที่ index.php แหละครับ

ลองเพิ่มตัวนี้เข้าไป
<?php endwhile; ?>

เป็น

อ้างถึง<?php $recent = new WP_Query("cat=7&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php the_content('Read more...'); ?></li></ul><?php endwhile; ?>

Normaderm

[direct=https://www.facebook.com/aiunlockedvip]สอน AI[/direct]| [direct=https://aiunlock.co/]คอร์ส AI[/direct] | [direct=https://aiunlock.co/]สอน n8n[/direct]  | [direct=https://www.aiunlockinnovations.com/]สอน AI เชียงใหม่[/direct]