คำสั่งแสดง 10 บทความล่าสุด แบบไม่แยกหมวดหมู่ใน WordPress ชุดนี้ ส่วนใหญ่จะเอาไว้ใช้สำหรับการเขียนหน้าเว็บเพจใหม่ จะไม่ใช้เป็นการนำเอาคำสั่งไปแทรกลงยังไฟล์ page.php หรือ single.php แต่จะทำหน้าเว็บเพจเฉพาะแยกขึ้นมาสำหรับประยุกต์ใช้ต่อไปครับ ซึ่งคำสั่งด้านล่างจะเอาไว้แสดงโพสต์หรือบทความที่เราเคยเอาลงไปในฐานข้อมูล ขึ้นมาแสดงบนหน้าเว็บเพจแบบไม่แยกหมวดหมู่ (category) คือจะดึงมาทั้งหมด 10 โพสต์ล่าสุด
<!-- Define our WP Query Parameters -->
<?php $the_query = new WP_Query( 'posts_per_page=10', 'offset'=> 1, 'category' => 1 ); ?>
<!-- Start our WP Query -->
<ul><?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<!-- Display the Post Title with Hyperlink -->
<li><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" target="_blank"><?php the_title(); ?></a></li>
<!-- Display the Post Featured Image -->
<li><?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('thumbnail');
} ?></li>
<!-- Repeat the process and reset once it hits the limit -->
<?php
endwhile;
wp_reset_postdata();
?></ul>
# posts_per_page=10 จะแสดงจำนวนโพสต์ตามที่ต้องการ




























https://towsoccerclub.com
ขอบคุณมากนะค่า ตอนนี้กำลังใช้ wordpress เหมือนกัน กำลังทำเว็บกีฬา กำลังศึกษาหาข้อมูลไปเรื่อยๆยังไงจะติดตามและอัพเดตต่อไปนะคะ
ถ้าติดปัญหาส่วนไหน ปรึกษาผมได้นะครับ