2015-02-07 4 views
1

이것은 내가 워드 프레스에서 사용해온 나쁜 습관이고 나는 멈추고 싶습니다. 한 번에 모두 가져와야 할 때 루프/쿼리 코드를 반복합니다. 다음은 그 예입니다 ...wordpress loop/query를 반복하지 않으려면 어떻게해야합니까?

<?php 
       $args = array(
       'p' => 9345, // id of a page, post, or custom type 
       'post_type' => 'front page content'); 

       $loop = new WP_Query($args); 

       //Display the contents 

       while ($loop->have_posts()) : $loop->the_post(); 
       the_content(); 
    endwhile; 

       $args = array(
       'p' => 9341, // id of a page, post, or custom type 
       'post_type' => 'front page content'); 

       $loop = new WP_Query($args); 

       //Display the contents 

       while ($loop->have_posts()) : $loop->the_post(); 

    the_content(); endwhile; 
?> 

내가 ID의 내용을 표시하려면 9345 제, 내가 이렇게 어떻게 모든 WP_Query를 복제하지 않고 ID 9341초의 내용? order_by에 대해 알고 있지만 쿼리의 결과를 구체적으로 정렬하려면 어떻게해야합니까?

답변

1

당신은 post__in 사용할 수 Read more

<?php 
    $args = array(
     'post__in' => array(9345, 9341), 
     'post_type' => 'page' 
    ) 

    $loop = new WP_Query($args); 

    //Display the contents 

    while ($loop->have_posts()) : $loop->the_post(); 
     the_content(); 
    endwhile; 

    //DONT FORGET THIS 
    wp_reset_postdata(); 
?> 
관련 문제