Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Wordpress主页上按类别和日期排序_Php_Wordpress - Fatal编程技术网

Php 在Wordpress主页上按类别和日期排序

Php 在Wordpress主页上按类别和日期排序,php,wordpress,Php,Wordpress,我的Wordpress站点有多个自定义类别和帖子类型,所有这些都需要显示在主页blogroll上。但是我需要首页上的第一篇文章总是某个特定类别的最新文章 例如,页面顶部的pst将始终是最新的“长颈鹿”类别;在它下面;按默认/时间顺序排序的是更多的“海象”与“海鸥”和“玉米片”的混合 实现这一点的最佳方法是什么?如果不重复循环两次,粘贴帖子是您的最佳选择 否则: ... $args = array( 'orderby' => 'post_date', 'category'=> 'g

我的Wordpress站点有多个自定义类别和帖子类型,所有这些都需要显示在主页blogroll上。但是我需要首页上的第一篇文章总是某个特定类别的最新文章

例如,页面顶部的pst将始终是最新的“长颈鹿”类别;在它下面;按默认/时间顺序排序的是更多的“海象”与“海鸥”和“玉米片”的混合


实现这一点的最佳方法是什么?

如果不重复循环两次,粘贴帖子是您的最佳选择

否则:

...
$args = array(
 'orderby' => 'post_date',
 'category'=> 'giraffe',
 'numberposts'=> 1,
);
$latest_giraffe_post = get_posts( $args );    
... 

然后做你已经在做的其他事情

你能不能在“长颈鹿”类的最新帖子中使用粘性帖子?