ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์CMS & Free Scriptwordpress อยากให้โพสตามหมวดหมู่ต้องแก้โค้ดยังไงครับ
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: wordpress อยากให้โพสตามหมวดหมู่ต้องแก้โค้ดยังไงครับ  (อ่าน 871 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
sweetlovestudio
Newbie
*

พลังน้ำใจ: 3
ออฟไลน์ ออฟไลน์

กระทู้: 57



ดูรายละเอียด เว็บไซต์
« เมื่อ: 21 มิถุนายน 2018, 13:04:28 »

หน้าที่แสดงหน้าแรก เป็นหน้า index.php ใช่มั้ยครับ

ตอนนี้แสดงเป็นโพสล่าสุดอยู่ครับ อยากให้โชว์เป็นโพสตามหมวดหมู่ครับ

ขอบคุณครับ


<?php if ( have_posts() ) : ?>

                        <?php /* Start the Loop */ ?>
                  
                     <?php while ( have_posts() ) : the_post(); ?>

                                <?php
                                    /* Include the Post-Format-specific template for the content.
                                     * If you want to override this in a child theme, then include a file
                                     * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                                     */
                                    get_template_part( 'loop-templates/content', get_post_format() );
                                ?>

                        <?php endwhile; ?>
                       
                    <?php else : ?>

                        <?php get_template_part( 'loop-templates/content', 'none' ); ?>
                       
                    <?php endif; ?>
บันทึกการเข้า

bsssweet
คนรักเสียว
*

พลังน้ำใจ: 5
ออฟไลน์ ออฟไลน์

กระทู้: 100



ดูรายละเอียด
« ตอบ #1 เมื่อ: 21 มิถุนายน 2018, 13:55:17 »

ถ้าแยกตาม Catagory มี Plugin แนะนำครับ ใช้ Content Views ก็ได้นะครับ
บันทึกการเข้า

จะเก่งหรือไม่อยู่ที่การฝึกฝน
ฟิลเลอร์ใต้ตา
tibox
sweetlovestudio
Newbie
*

พลังน้ำใจ: 3
ออฟไลน์ ออฟไลน์

กระทู้: 57



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 21 มิถุนายน 2018, 14:52:42 »

ขอบคุณครับ

พอดีอยากลองแบบไม่ใช้ plugin นะครับ
บันทึกการเข้า

poseidon
บุคคลทั่วไป
« ตอบ #3 เมื่อ: 04 กรกฎาคม 2018, 11:01:48 »

<?php query_posts('cat=5'); ?>/* ตัวเลขแทน หมายเลขของ Category */
<?php if ( have_posts() ) : ?>

                        <?php /* Start the Loop */ ?>
                 
                     <?php while ( have_posts() ) : the_post(); ?>

                                <?php
                                    /* Include the Post-Format-specific template for the content.
                                     * If you want to override this in a child theme, then include a file
                                     * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                                     */
                                    get_template_part( 'loop-templates/content', get_post_format() );
                                ?>

                        <?php endwhile; ?>
                       
                    <?php else : ?>

                        <?php get_template_part( 'loop-templates/content', 'none' ); ?>
                       
                    <?php endif; ?>
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์