Profile image
Tác giả: fcwordpress
Trang tin cá nhân | Bài đã đăng
Lượt xem

Hiện tại:
1h trước:
24h trước:
Tổng số:
Các function liên quan đến term trong wordpress
Sunday, June 28, 2015 2:42
% of readers think this story is Fact. Add your two cents.
0

Hôm nay tôi sẽ chia sẽ với anh/chị bài viết “Các function liên quan đến term trong wordpress”. Chúng ta trong quá trình làm theme thì sẽ gặp vấn đề như tôi nói dưới đây:

  • Tôi muốn lấy list term
 'name', 'order' => 'ASC', 'hide_empty' => false, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 'hierarchical' => true, 'child_of' => 0, 'childless' => false, 'get' => '', 'name__like' => '', 'description__like' => '', 'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core' ); $categories = get_terms( "category", $args );

  • Lấy link term

  • Lấy thông tin term từ term_id
slug; $name = $term->name; $desc = $term->description; ?>
  • Lấy thông tin term từ post id
  name; ?>   ?>
  • Lấy thông tin term con từ parent term id
'; foreach ( $termchildren as $child ) { $term = get_term_by( 'id', $child, $taxonomy_name ); echo '
  • ' . $term->name . '
  • '; } echo ''; ?>
    • Lấy thông tin term cha từ child term id
       //returns: Array ( [0] => 23 [1] => 6 ) //Child Page (448)  //returns: Array ( [0] => 447 )
    • Lấy list term hiện tại của bài viết
    ID, 'on-draught' ); if ( $terms && ! is_wp_error( $terms ) ) : $draught_links = array(); foreach ( $terms as $term ) { $draught_links[] = $term->name; } $on_draught = join( ", ", $draught_links ); ?> 

    On draught:

    BÌNH LUẬN

    Lời bình của bạn
    Question   Razz  Sad   Evil  Exclaim  Smile  Redface  Biggrin  Surprised  Eek   Confused   Cool  LOL   Mad   Twisted  Rolleyes   Wink  Idea  Arrow  Neutral  Cry   Mr. Green

    Tin nổi bật trong ngày
    Tin mới nhất

    Register

    Newsletter

    Email this story
    Share This Story:
    Print this story
    Email this story
    Digg
    Reddit
    StumbleUpon
    Share on Tumblr
    GET ALERTS:

    If you really want to ban this commenter, please write down the reason:

    If you really want to disable all recommended stories, click on OK button. After that, you will be redirect to your options page.