wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_set_post_terms › WordPress Function
Since2.8.0
Deprecatedn/a
› wp_set_post_terms ( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false )
Parameters: (4) |
|
See: | |
Returns: |
|
Defined at: |
|
Codex: |
Set the terms for a post.
Related Functions: wp_get_post_terms, wp_set_post_cats, wp_set_post_tags, wp_set_object_terms, wp_set_post_categories
Source
function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) { $post_id = (int) $post_id; if ( ! $post_id ) { return false; } if ( empty( $tags ) ) { $tags = array(); } if ( ! is_array( $tags ) ) { $comma = _x( ',', 'tag delimiter' ); if ( ',' !== $comma ) { $tags = str_replace( $comma, ',', $tags ); } $tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) ); } /* * Hierarchical taxonomies must always pass IDs rather than names so that * children with the same names but different parents aren't confused. */ if ( is_taxonomy_hierarchical( $taxonomy ) ) { $tags = array_unique( array_map( 'intval', $tags ) ); } return wp_set_object_terms( $post_id, $tags, $taxonomy, $append ); }