[英]Fetch and display Wordpress category of custom post type
我目前正在从事一个个人项目,此页面基本上有两个选项卡,每个选项卡将在一种称为“网络研讨会”的自定义帖子类型下显示特定类别的存档。
我正在使用以下选项卡之一调用类别
<?php query_posts('category_name=demos-on-demand-videos'); ?>
但是,当我这样做时,我只会看到找不到帖子的屏幕,我在做什么错? 我正在尝试显示在线研讨会自定义帖子类型下的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;
请点击以下链接: http : //eyan16.wordpress.com/2013/09/16/how-to-fetch-posts-from-custom-posts-type-with-custom-taxonomy/
为每个选项卡制作一个页面模板,并在其中使用此自定义循环。 确保根据您的特定职位类型,分类或术语进行调整。
<?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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.