在我想显示的搜索结果页面上a tag list 从搜索结果列出的其他帖子中收集。
// same tag should not be listed twice
以及分类页面;为当前标记列出的其他帖子的标记。我试着用get_the_tags(array(post ids))
但没能成功。
非常感谢。
在我想显示的搜索结果页面上a tag list 从搜索结果列出的其他帖子中收集。
// same tag should not be listed twice
以及分类页面;为当前标记列出的其他帖子的标记。我试着用get_the_tags(array(post ids))
但没能成功。
非常感谢。
您可以使用下面的简单解决方案。您需要在循环中使用此函数。您可以收集阵列中的标记/类别,或在帖子下显示标记/类别。
$terms = get_the_terms( get_the_ID(), \'category\' );
if ( $terms && ! is_wp_error( $terms ) ) :
$catlinks = array();
foreach ( $terms as $term ) {
$catlinks[] = $term->name;
}
$catso = join( ", ", $catlinks );
?>
<p class="list-of-cats">
<?php printf( esc_html__( \'Categories: <span>%s</span>\', \'textdomain\' ), esc_html( $catso ) ); ?>
</p>
是否可以将变量传递给get_search_form()? 我在两个地方使用它:一个在标题中,另一个在内容的搜索页面上。后者必须具有附加类,例如。search--full. 我试着用is_search() 但尽管它在其他页面上运行良好,但在搜索页面上,两种表单都有search--full 班