質問

I have a wordpress (v. 3.8) loop that shows 5 future posts:

<?php 
$temp = $wp_query; 
$wp_query = null; 
$wp_query = new WP_Query(); 
$wp_query->query('showposts=5&post_type=events&post_status=future&orderby=date&order=ASC'.'&paged='.$paged); 

while ($wp_query->have_posts()) : $wp_query->the_post(); 
?>

The posts (custom post type "events") are sorting with the "planed" date but i want the newest created post to be on top.

役に立ちましたか?

解決

One of the best feature that every WP programmer should know is the ability to schedule his posts in WordPress. This feature can do more then letting you schedule your post to publish at a certain time.

BUT: there is one caveat using the future posts display - there is no valid DATE field to sort on as the date for those future posts is not yet SET.

You could try however with orderby=ID / orderby=modified and order=ASC (of course, assuming the sequence in your future posts by ID is the same sequence as their future dates).

他のヒント

orderby=ID

Did the job. The only question is: when i re-plan a post, how can i move it to top?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top