我正在尝试获取标签列表,并在页面上列出它们,但不链接到它们的存档页面。
目前我正在这样做:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_the_term_list( $post->ID, \'visits\', \'Visits \', \', \', \' \' );
wp_reset_query();
?>
谢谢我正在尝试获取标签列表,并在页面上列出它们,但不链接到它们的存档页面。
目前我正在这样做:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_the_term_list( $post->ID, \'visits\', \'Visits \', \', \', \' \' );
wp_reset_query();
?>
谢谢您可以使用get_the_terms()
. 我根据该页上的一个示例改编了以下内容:
$terms = get_the_terms( $post->ID, \'visits\' );
if ( $terms && ! is_wp_error( $terms ) ) :
$visits_name = array();
foreach ( $terms as $term ) {
$visits_name[] = $term->name;
}
$terms_list = join( ", ", $visits_name );
echo $terms_list;
endif;
EDIT:
使用wp_list_pluck
, 根据建议Telos, 更容易:$terms = get_the_terms( $post->ID, \'visits\' );
if ( $terms && ! is_wp_error( $terms ) ) :
echo join( \',\', wp_list_pluck( $terms, \'name\' ) );
endif;
列出自定义分类法中的所有术语,不带链接:
$terms = get_terms("my_taxonomy");
$count = count($terms);
if ( $count > 0 ){
echo "<ul>";
foreach ( $terms as $term ) {
echo "<li>" . $term->name . "</li>";
}
echo "</ul>";
}
列出所有术语,并链接到术语存档,用interpunt(·)分隔。(特定语言,WPML方法):$args = array( \'taxonomy\' => \'my_term\' );
$terms = get_terms(\'my_term\', $args);
$count = count($terms); $i=0;
if ($count > 0) {
$cape_list = \'<p class="my_term-archive">\';
foreach ($terms as $term) {
$i++;
$term_list .= \'<a href="/term-base/\' . $term->slug . \'" title="\' .sprintf(__(\'View all post filed under %s\', \'my_localization_domain\'), $term->name) . \'">\' . $term->name . \'</a>\';
if ($count != $i)
$term_list .= \' · \';
else
$term_list .= \'</p>\';
}
echo $term_list;}
有关更多详细信息:get_terms()
.好吧,我会用这个:
echo strip_tags(get_the_term_list( $post->ID, \'visits\', \'Visits \', \', \', \' \' ));编辑:我们使用strip_tags() 停用链接。这必须在循环中使用。
假设我在管理仪表板中创建了一个页面,并在其中放置了一些内容。如何在托管文件管理器中找到包含该内容的PHP文件?