我对按邮寄日期排序有一个奇怪的问题。
我创建了一个幻灯片帖子类型,默认情况下,它会按发布日期排序,但如果我通过管理员更改发布日期,则订单不会在查询中更新,但会在管理员中更新。
岗位类型
/* Slideshow Post Type */
add_action(\'init\', \'slide_init\');
function slide_init() {
$labels = array(
\'name\' => _x(\'Slides\', \'post type general name\'),
\'singular_name\' => _x(\'Slide\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'slide\'),
\'add_new_item\' => __(\'Add New Slide\'),
\'edit_item\' => __(\'Edit Slide\'),
\'new_item\' => __(\'New Slide\'),
\'view_item\' => __(\'View Slide\'),
\'search_items\' => __(\'Search Slides\'),
\'not_found\' => __(\'No slides found\'),
\'not_found_in_trash\' => __(\'No slides found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Homepage Slides\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\', \'editor\', \'thumbnail\')
);
register_post_type(\'slide\', $args);
}
查询
// Slideshow Query
$slideshow_args = array(
\'post_type\' => \'slide\',
\'posts_per_page\' => \'10\',
);
$slideshow = new WP_Query( $slideshow_args );
编辑--
我发现这与这行代码有关。
$slideshow_post_count = $slideshow->post_count;
<?php if ($slideshow_post_count > 1) : ?>
<div class="controls span6">
<span class="next"></span>
<span class="pause"></span>
<span class="prev"></span>
</div>
<?php endif; ?>