我有一个自定义查询,我试图运行。我多么希望它的工作是,查询自定义分类wordpress错误
首先,检查页面标题
如果网页标题是一样的,从一个自定义分类猫的名字,然后显示所有可在帖子在那个自定义分类中 - 发布类型。
唯一的麻烦是,它不返回任何东西,我确信我针对正确的“柱式” &正确的“分类”的名字。它将返回猫ID改为:
$cat->cat_ID;
,但不会返回任何帖子,这里是我的代码:
<?php
// Get the name of the page
$theTitle = get_the_title();
//Get the taxonomy for the custom post type
$categoryselect = array('taxonomy' => 'team-members');
$categories = get_categories($categoryselect);
// loop through each category as cat
foreach ($categories as $cat):
//If cat is the same as title *name* then lets do something
if($theTitle == $cat->cat_name):?>
<h3>We’re here to help.</h3>
<?php
$catID = $cat->cat_ID;
//echo $catID;
//query the posts but, use the cat ID so the page relates to it.
$args = query_posts(array('post_type' => 'team', 'cat'=> $catID, 'orderby' => 'title', 'showposts' => -1));
$loop = new WP_Query($args);
// run the loop for posts
while ($loop->have_posts()) : $loop->the_post();?>
<div class="person">
<h5><?php the_title(); ?></h5>
</div>
<?php endwhile;
endif;
endforeach;
这是一个page.php文件模板
任何建议?
这个页面/模板是这个 – 2014-10-16 14:52:02
它运行在page.php – 2014-10-16 15:07:05