以下代码仅检索具有自定义分类学“滑块”的自定义帖子类型。

我想将他们的命令更改为ASC。

编码:

<?php // Retrive custom post type with a custom taxonomy assigned to it
 $posts = new WP_Query('post_type=page_content&page_sections=Slider (Front Page)') ?>
 <?php while ( $posts->have_posts() ) : $posts->the_post(); ?>
 <?php the_content(); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>

不确定我是否应该使用数组(无论如何如何)。

有什么建议么?

有帮助吗?

解决方案

只需在您的代码中更改此行:

 $posts = new WP_Query('post_type=page_content&page_sections=Slider (Front Page)') ?>

为此:

 $posts = new WP_Query('post_type=page_content&page_sections=Slider (Front Page)&order=ASC') ?>

基本上,它添加了订单参数女巫可以采用两个值(ASC,desc)。

希望这可以帮助。

其他提示

您想实现哪种订单?时间顺序?字母顺序?

无论如何,请参阅 订单和订单参数 在Codex中进行可用参数。

许可以下: CC-BY-SA归因
scroll top