Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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,我目前正在从事一个个人项目,该页面基本上有两个选项卡,每个选项卡将在一个名为webinar的自定义帖子类型下显示特定类别的存档 我正在使用调用其中一个选项卡中的类别 <?php query_posts('category_name=demos-on-demand-videos'); ?> 然而,当我这样做的时候,我只是得到了“找不到帖子”屏幕,我做错了什么?我正在尝试显示webinar自定义帖子类型下的类别demos on demand videos中的帖子存档。使用此选项

我目前正在从事一个个人项目,该页面基本上有两个选项卡,每个选项卡将在一个名为webinar的自定义帖子类型下显示特定类别的存档

我正在使用调用其中一个选项卡中的类别

<?php query_posts('category_name=demos-on-demand-videos'); ?>

然而,当我这样做的时候,我只是得到了“找不到帖子”屏幕,我做错了什么?我正在尝试显示webinar自定义帖子类型下的类别demos on demand videos中的帖子存档。

使用此选项

query_posts( array( 'post_type' => 'webinar','your-custom-taxnomy' => 'demos-on-demand-videos' ) );

while ( have_posts() ) :
the_post(); 
$post_id = $post->ID;
endwhile;   

请点击此链接:
为每个选项卡制作一个页面模板,并在其中使用此自定义循环。确保根据您的特定帖子类型、分类法或术语对其进行调整

<?php $args=array( 
'post_type' => 'webinar', //set the post_type to use.
'taxonomy' => 'demos-on-demand-videos', // set the taxonomy to use.
'term' => 'term1', //set which term to use or comment out if not using. 
'posts_per_page' => 10  // how many posts or comment out for all.       
);

$webinarloop = new WP_Query($args);
if($webinarloop->have_posts()) : while($webinarloop->have_posts()) :
$webinarloop->the_post();

get_template_part( 'content' ); //or whatever method you use for displaying your content. 

endwhile; endif; //end the custom post_type loop

?>

这个代码对我来说很好
*x是您创建的分类名称 *y是类别段塞

      $args = array('post_type' => 'client','posts_per_page'=>'8','order'=>'DESC','x'=>'y');

$loop = new WP_Query( $args );  
while ( $loop->have_posts() ) : $loop->the_post();