不确定是否曾经有人问过这个问题,但是我有点迷茫。我用“新闻编辑室”类别的自定义分类法创建了“新闻编辑室”窗格。新闻编辑室类别包含3个字段:新闻稿,媒体,其他。我有一个WordPress页面模板: obj q ref x y
0 901 [] NaN 1 1
1 907 [(3, 3)] [907] 1 2
2 884 [] NaN 1 3
3 485 [(2, 2), (3, 3)] [814, 739] 2 1
4 814 [] NaN 2 2
5 491 [] NaN 2 3
6 822 [] NaN 3 1
7 752 [] NaN 3 2
8 739 [(1, 3), (2, 1)] [884, 485] 3 3
taxonomy-newsroom_category.php
用于显示Pod帖子,如果满足以下条件:
taxonomy-newsroom_category.php
我现在的问题是我找不到显示帖子详细信息的方法:
1 - pods = 'newsroom'
2 - taxonomy = 'press_release' || 'media' || 'others'
,image(thumbnail)
,title(post title)
我希望有人能提供帮助。谢谢
这是我当前正在使用的代码:
date_published
答案 0 :(得分:0)
我还为此找到了解决方案...我有“自定义帖子类型”“研究”,并且必须基于自定义分类类别对它们进行过滤。如果要编写一种分类类别的帖子,请尝试使用类似这样的内容:
$type = $_GET['type'];
$args = array(
"post_type" => "studien",
"post_per_page" => -1,
"relation" => "AND"
);
if($type != "") {
$args['tax_query'][] = array(
'taxonomy' => 'market',
'field' => 'slug',
'terms' => $type
);
$wp_query = new WP_Query($args);
}
$type
代表我创建的分类法中的一个类别(值来自选择选项中的HTML代码),$args
是对数据库的某些查询,而“市场”是我的自定义分类法的子弹,{{1 }}返回所有过滤器帖子
我的自定义分类中自定义帖子类型的屏幕截图。如您所见,我分为两个小组。首先在两个帖子中单击,然后在最后两个帖子中单击。也许它将帮助您发挥想象力
答案 1 :(得分:0)
检查https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters。本文档详细说明了如何使用自定义帖子类型和分类进行查询。您的代码可能是这样的。
$args = array(
'post_type' => 'newsroom',
'tax_query' => array(
array(
'taxonomy' => 'newsroom_category',
'field' => 'slug',
'terms' => 'press_release',
),
),
);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$id = get_the_ID(); // with post id, you can get whatever you want.
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
答案 2 :(得分:0)
来自wordpress文档:
https://codex.wordpress.org/Custom_Taxonomies
我们为分类人员提供以下内容
$ args =数组( 'tax_query'=>数组( 数组( '分类法'=>'人', 'field'=>'slug', '条款'=>'鲍勃' ) ) ); $ query =新的WP_Query($ args);