ĐĂNG TIN
logo
Online:
Visits: 1,686,943,740
Stories: 8,387,788
Profile image
0
0
Tác giả: fcwordpress
Trang tin cá nhân | Bài đã đăng
Lượt xem

Hiện tại:
1h trước: 1
24h trước: 1
Tổng số: 88
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.


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:

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

    Register

    Newsletter

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