Các Function Liên Quan Đến Term Trong Wordpress (ok)
https://fcwordpress.net/cac-function-lien-quan-den-term-trong-wordpress.html
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:
Get id term trong taxonomy template
global $wp_query;
$term_id = $wp_query->get_queried_object();
$term_id->term_idTôi muốn lấy list term
<?php
// mảng taxonomies
$taxonomies = array(
'post_tag',
'my_tax',
);
$args = array(
'orderby' => '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
Lấy thông tin term từ term_id
Lấy thông tin term từ post id
Get id term parent từ id term child
Get id term child từ id term parent
PreviousSử dụng wp_set_object_terms để ghi taxonomy tùy chỉnh cho bài viết ví dụ gắn chuyên mục với post (okNextget_terms, get_term (ok)
Last updated
Was this helpful?