function get_the_terms( $post, $taxonomy ) { $post = get_post( $post ); if ( ! $post ) { return false; } $terms = get_object_term_cache( $post->ID, $taxonomy ); if ( false === $terms ) { $terms = wp_get_object_terms( $post->ID, $taxonomy ); if ( ! is_wp_erro...
有些说,您可以在循环外部使用get_terms,而只能在循环内部使用get_the_terms。 但并非如此,您也可以在循环外部使用get_the_terms(),例如: $categories = get_the_terms( $id, 'product_cat' ); 在get_the_terms中,您可以通过特定的post_id获取术语,但是在get_terms中,您可以获取一...
get_the_category和get_the_terms貌似都是用来获取分类信息的,前者使用方法简单,不带参数,后者使用方法 <?php get_the_terms( $id, $taxonomy ); ?> 例如:woocommerce中,获取当前产品页面的分类信息,前者居然无效,后者要使用 <?php get_the_terms( $id, 'product_cat'); 为什么要填写'product_cat',我...
有两种方法可以找到所有具有匹配帖子的术语。一是找到所有的帖子,检查它们的所有条款,这就是你要做的。
get_the_terms›WordPress Function Since2.5.0 Deprecatedn/a ›get_the_terms ($post,$taxonomy) Parameters: (2) (int|WP_Post)$postPost ID or object. Required:Yes (string)$taxonomyTaxonomy name. Required:Yes Returns: (WP_Term[]|false|WP_Error) Array of WP_Term objects on success, fals...
add_action('woocommerce_single_product_summary' , 'cat_type_before_title', 3); function cat_type_before_title() { global $post; $terms = wp_get_post_terms( get_the_ID(), 'product_cat', array( 'orderby' => 'parent' ) ); foreach ( $terms as $term ) { $term_link = get_te...
$terms(WP_Term[]|WP_Error) Array of attached terms, or WP_Error on failure. $post_id(int) Post ID. $taxonomy(string) Name of the taxonomy. Changelog Since 3.1.0Introduced. Where the hook is called get_the_terms() get_the_terms ...
Get the terms right.Presents a letter to the editor in reference to an article on the U.S. National Institute of Health and its state-of-the-science conference on hormone replacement therapy.EBSCO_bspDrug Topics
$post_terms = get_the_terms( $block->context['postId'], $attributes['term'] ); if ( is_wp_error( $post_terms ) || empty( $post_terms ) ) { return ''; } cc @david-binda Fix: return empty string instead of false Verified f3afb61 Contributor david-binda commented Oct ...
Get the auto renewal terms of an agreement Get the dimensions purchased in an agreement Get the instances of each dimension purchased in an agreement Get the payment schedule of an agreement Get the pricing per dimension in an agreement