[英]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.