ĐĂNG TIN
logo
Online:
Visits: 1,686,975,496
Stories: 8,387,830
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ố: 72
Các function liên quan đến term trong wordpress
Saturday, January 2, 2016 1:54
% 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' => true, 'include' => array(), 'exclude' => array(), 'exclude_tree' => array(), 'number' => '', 'offset' => '', 'fields' => 'all', 'name' => '', 'slug' => '', 'hierarchical' => true, 'search' => '', 'name__like' => '', 'description__like' => '', 'pad_counts' => false, 'get' => '', 'child_of' => 0, 'parent' => '', 'childless' => false, 'cache_domain' => 'core', 'update_term_meta_cache' => true, 'meta_query' => '' ); $terms = get_terms($taxonomies, $args); ?>
  • Lấy link term
get_term_link( (int) $term_id,'product_cat') get_term_link($term_id,'product_cat')(đối tượng);
  • Lấy thông tin term từ term_id
$term = get_term($idpage1,'product_cat') $term->name;
  • Lấy thông tin term từ post id
$singer = get_the_terms( get_the_ID(), "product_singer" );  name; ?>  
  • Get id term parent từ id term child
 returns: Array ( [0] => 23 [1] => 6 )
  • Get id term child từ id term parent
'; foreach ( $termchildren as $child ) { $term = get_term_by( 'id', $child, $taxonomy_name ); echo '
  • ‘ . $term->name . ‘
  • ‘; } echo ”; ?>

    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.