Wordpress获取当前帖子术语

代码示例

6
0

//Get all terms (names) of a taxonomy of a post
$term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
5
0

wordpress获取帖子的分类

<?php $term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
1
0

// RETRIVE TERM SLUG ( for single.php or template-part )

$terms = get_the_terms( $post->ID, 'your-taxonomy' );
if ( !empty( $terms ) ){
    // get the first term
    $term = array_shift( $terms );
    echo $term->slug;
}
1
0

在singhle post中获取分类名称

// RETRIVE TERM SLUG ( for single.php or template-part )

$terms = get_the_terms( $post->ID, 'your-taxonomy' );
if ( !empty( $terms ) ){
    // get the first term
    $term = array_shift( $terms );
    echo $term->slug;
}
0
0

$posts = get_posts(array('name' => 'your-posts-name', 'post_type' => 'faq'));

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................