wp_get_object_terms( int|array $object_ids, string|array $taxonomies, array|string $args = array() ) Retrieves the terms associated with the…
Remove the post format prefix from the name property of the term objects created by wp_get_object_terms(). WordPress lookup for _post_format_wp_get_object_terms, a WordPress Function.
wp_get_object_termswp_set_object_termsupdate_object_term_cachewp_add_object_termswp_remove_object_terms 引入2.3.0弃用 -wp_delete_object_term_relationships:此函数删除给定对象的所有术语关系。它将对象ID和分类名称作为参数,并从WordPress数据库中删除该对象和分类的所有术语关系。从...
wp_get_post_terms( int $post_id, string $taxonomy = 'post_tag', array $args = array() ) Retrieve the terms for a post. description There is …
因为wp_set_post_terms使用intval函数在处理层级关系的分类模式时对$terms数组中的每个元素做了强类型转换。所以也为了防止冲突,他也直接接受 IDs 方式的参数。 wp_set_object_terms也可以给给文章设置分类,但是他就没有类型转换的功能。这也是要注意的一点。
php$taxonomy='category';// 获取某篇文章的分类id$post_terms=wp_get_object_terms($post->ID,$taxonomy,array('fields'=>'ids'));// 用逗号分隔不同的分类链接$separator=', ';if(!empty($post_terms)&&!is_wp_error($post_terms)){$term_ids=implode(',',$post_terms);$terms=wp_list_...
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); // 用逗号分隔不同的分类链接 $separator = ', '; if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) { $term_ids = implode( ',' , $post_terms ); ...
类似于 get_the_category_list() 函数(根据名称排序分类)。这个例子必须使用内循环。 $taxonomy = 'category'; // Get the term IDs assigned to post. $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); // Separator between links. $separator = ', ...
根据父-子关系来排序文章的分类。类似于 get_the_category_list() 函数(根据名称排序分类)。这个例子必须使用内循环。 $taxonomy='category'; // Get the term IDs assigned to post. $post_terms=wp_get_object_terms($post->ID,$taxonomy,array('fields'=>'ids')); ...
$term_group = $wpdb->get_var( "SELECT MAX(term_group) FROM $wpdb->terms" ) + 1; wp_update_term( $alias->term_id, $taxonomy, array( 'term_group' => $term_group, ) ); } $parsed_args['term_group'] = $term_group; } /** * Filters the term parent. * * Hook to this fi...