พี่ๆครับ รบกวนดูโค้ดหน้าแรกให้ผมหน่อยครับ พอดีผมสร้างหน้าโฮมเพจ แบบ เลือกโพสได้ว่าจะเอาโพสไหนอยู่ อันดับ 1 2 3 ในหน้าแรก แต่ทีนี้ โค้ดมันยาวไปหน่อยอ่ะครับ ใช้ฟังก์ชั่นใช้งานก็ ซ้ำๆ กัน เรยอยากจะถามว่า มันมีวิธีที่ทำให้ ฟังก์ชั่นทำงาน ไม่ซ้ำกันไม๊ครับ อันนี้เป็นของ wordpress ครับ อันที่ซ้ำกันคือ
$postid=array( $moso_options ['postid1'] );
อันนี้อ่ะครับ รับค่าจาก postid1,postid2,postid3 รบกวนพี่ๆช่วยผมหน่อยน๊ะครับ ^^

<?php global $moso_options; ?>
<?php get_header(); ?>
<?php if (have_posts()) : ?>
<?php
$postid=array( $moso_options ['postid1'] ); //post id = 7
// The Query
$my_query = new WP_Query( array( 'post__in' =>$postid ) );
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php
$postid=array( $moso_options ['postid2'] );//post id = 54
// The Query
$my_query = new WP_Query( array( 'post__in' =>$postid ) );
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php
$postid=array( $moso_options ['postid3'] ); //post id = 4
// The Query
$my_query = new WP_Query( array( 'post__in' =>$postid ) );
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php
$postid=array( $moso_options ['postid4'] ); //post id = 10
// The Query
$my_query = new WP_Query( array( 'post__in' =>$postid ) );
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php
$postid=array( $moso_options ['postid5'] ); //post id = 108
// The Query
$my_query = new WP_Query( array( 'post__in' =>$postid ) );
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>