是一个用于WordPress开发的函数,用于获取指定文章的分类术语(terms)。下面是对该函数的完善和全面的答案: 合并wp_get_post_terms函数是一个用于WordPress开发的函数,用于获取指定文章的分类术语(terms)。该函数可以用于获取文章的标签、分类目录等信息。 函数的语法如下: ...
function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) { $post_id = (int) $post_id; $defaults = array( 'fields' => 'all' ); $args = wp_parse_args( $args, $defaults ); $tags = wp_get_object_terms( $post_id, $taxonomy, $args ); ret...
因为wp_set_post_terms使用intval函数在处理层级关系的分类模式时对$terms数组中的每个元素做了强类型转换。所以也为了防止冲突,他也直接接受 IDs 方式的参数。 wp_set_object_terms也可以给给文章设置分类,但是他就没有类型转换的功能。这也是要注意的一点。
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函数的参数: $post_id:文章 ID。 $terms:分类或者标签数据。 $taxonomy:分类模式,默认post_tag $append:是否附加还是直接覆盖,默认覆盖,如果要添加,这个参数设置为 false。 这个函数的重点就是地第二个参数$terms,根据官方的注释,$terms可以是数组或者逗号分隔的字符串。
wp_get_object_terms( int|array $object_ids, string|array $taxonomies, array|string $args = array() ) Retrieves the terms associated with the…
}wp_set_post_terms($id, $params['type'], FEEDBACK_TYPE); do_action('un_feedback_created', $id, $params);$this->send_admin_message($id, $params); } 开发者ID:congtrieu112,项目名称:anime,代码行数:25,代码来源:model.php 示例2: create ...
Gets data about terms that previously shared a single term_id, but have since been split. Related Functions:wp_get_split_term,wp_get_post_terms,_wp_batch_split_terms,wp_get_sites,wp_set_post_terms Source functionwp_get_split_terms($old_term_id){$split_terms= get_option('_split_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.$separ...
在下文中一共展示了wp_get_split_terms函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。 示例1: custom_output_option ▲点赞 7▼ /** * Use custom callback for outputting snippet ...