2014-09-04 2 views
0

페이지의 모든 게시물 목록에 향후 게시물을 표시해야합니다.워드 프레스 및 향후 게시물

내 코드

$args = array('posts_per_page' => 10, 
       'category' => $category->cat_ID); 
          ?> 

<?php $posts = get_posts($args); ?> 

제가 미래의 게시물과 카테고리의 모든 게시물을 보여주는 쓰기 위해 할 수있는 인수?

그리고 카테고리

<?php if (have_posts()) : ?> 
         <?php while (have_posts()) : the_post(); ?> 
         <?php endwhile; ?> 
<?php endif; ?> 

미래와 과거의 게시물을 표시하려면이 솔루션 돛대 게시물 목록을 보여해야하는지 내 아카이브 페이지 코드는 너무

답변

1

당신은 일하기 위해 post_status를 지정해야 publishfuture$args에서 예를 들면 다음과 같습니다.

$args = array(
    'posts_per_page' => 10, 
    'category' => $category->cat_ID, 
    'post_status' => array(
     'publish', 
     'future' 
    ) 
); 

인수는, (예를 들어) 사용

$posts = get_posts($args); 

는,이 게시물을 표시 (예를 들어)을 사용하려면 :

foreach($posts as $p) { 

    // display the post title 
    echo '<h2>' . apply_filters('the_title', $p->post_title) . '</h2>'; 

    // display the post date 
    echo '<h4>' . date('F jS, Y', strtotime($p->post_date)) . '</h4>'; 

    // display an excerpt of the post 
    echo wp_trim_excerpt($p->post_content); 
} 

대안이/WP_Query이 게시물을 얻을 query_posts를 사용하는 것입니다. 이 경우 게시물을 표시하려면 질문과 비슷한 루프를 사용하십시오. 여기에 그 예가 나와 있습니다 : http://codex.wordpress.org/Class_Reference/WP_Query#Standard_Loop

+0

thanx. 좋아. secont 상황에 대한 어떤 제안? – waldemar

+0

나는 이것을 달성하기 위해 몇 가지 예제 코드를 보여주기 위해 위의 대답을 편집했다. –

+0

IE에서 예약 된 포스트를 열려고하면 404 오류가 발생합니다. 다른 브라우저에서는 모두 ok입니다. – waldemar

관련 문제