Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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-特定类别post循环_Php_Wordpress - Fatal编程技术网

Php Wordpress-特定类别post循环

Php Wordpress-特定类别post循环,php,wordpress,Php,Wordpress,我想创建一个循环来获取特定类别ID的帖子。 第一个帖子是这个类别的最新帖子,其他帖子都在下面 所以我有一个ID为=“190”的类别,如何根据此设计获得此帖子?>> 2017年11月2日 10 艾亚德·阿什拉夫 Lorem ipsum dolor sit amet,Concertmagna aliqua。ex ea commodo consequat。两个人都是精英,多洛在沃鲁帕特·维利特的《复仇者》中 2017年11月2日 100 2017年11月2日 100 2017年11月2日 100

我想创建一个循环来获取特定类别ID的帖子。 第一个帖子是这个类别的最新帖子,其他帖子都在下面

所以我有一个ID为=“190”的类别,如何根据此设计获得此帖子?>>


2017年11月2日
10
艾亚德·阿什拉夫
Lorem ipsum dolor sit amet,Concertmagna aliqua。ex ea commodo consequat。两个人都是精英,多洛在沃鲁帕特·维利特的《复仇者》中

2017年11月2日 100 2017年11月2日 100 2017年11月2日 100 2017年11月2日 100
试试这个

 $args = array(
     'cat' => 190, --> your category ID
     'posts_per_page' => 10
 );
 $the_query = new WP_Query( $args );

 // The Loop
 if ( $the_query->have_posts() ) {

    while ( $the_query->have_posts() ) {

        // ## write your code here..
    }
 }
您必须输入类别ID。如果您有类别名称,请使用:

$args = array(
   'category_name' => <your category name>
);
$args=array(
“类别名称”=>
);

问题已解决。非常感谢普拉布, 问题的解决方法是在之前添加$the_query->

$the_query-> _post();
/*功能2*/
函数et_模块($atts,$content=null){
提取(
短码(
排列(
'类型'=>'',
), 
$atts
)
);
ob_start();
?> 


您尝试过任何循环吗?对于这个内存问题,您可以在wp-config.php中添加它,然后尝试,//增加wp内存限制define('wp_MAX_memory_Limit','256M');感谢它工作正常谢谢您的回复,我使用了您的代码逻辑并进行了一些更新,请查看。 the_post();