我需要创建一个页面,在该页面中,我可以根据GET 请求(例如$_GET[\'search_cat\']
) 使用WP_QUERY
. 我只想根据来自不同页面的用户的查询列出任何类别的所有子类别。
Now, how can I list all of the subcategories searching through all of the subcategories of any category (which are actually custom taxonomy)?
提前谢谢。
我需要创建一个页面,在该页面中,我可以根据GET 请求(例如$_GET[\'search_cat\']
) 使用WP_QUERY
. 我只想根据来自不同页面的用户的查询列出任何类别的所有子类别。
Now, how can I list all of the subcategories searching through all of the subcategories of any category (which are actually custom taxonomy)?
提前谢谢。
终于想出了解决办法。如果有人觉得有用就回答。哪里$_GET[\'s_qr\']
具有来自另一个页面的用户的搜索查询。
$i = 0;
$parent_name = \'\';
$taxonomyName = "product-cat";
$search_r = array();
$parent_terms = get_terms( $taxonomyName, array( \'parent\' => 0, \'orderby\' => \'slug\', \'hide_empty\' => false ) );
foreach ( $parent_terms as $pterm ) {
$parent_name_1 = $pterm->name;
$terms = get_terms( $taxonomyName, array( \'parent\' => $pterm->term_id, \'orderby\' => \'slug\', \'hide_empty\' => false ) );
foreach ( $terms as $term ) {
//Find if the the category name has the search query
if (stripos($term->name, $_GET[\'s_qr\']) !== false) {
$search_r[\'item\'][$i] = $term->name. " in ".$parent_name_1;
$i++;
}
}
}
print_r($search_r);
嗨,我目前正在为我的博客构建一个主题。下面的代码指向最新的帖子(特色帖子)。因为这将有一个不同的风格比所有其他职位。然而我想过滤掉帖子格式:链接使用我在循环中定义的WP查询,因为它给我带来了更多的灵活性。我该怎么做呢? <?php $featured = new WP_Query(); $featured->query(\'showposts=1\'); ?> <?php while ($featured->have_post