Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_set_post_terms [ WordPress Function ]

wp_set_post_terms ( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false )
Parameters:
  • (int) $post_id Post ID.
  • (string) $tags The tags to set for the post, separated by commas.
  • (string) $taxonomy Taxonomy name. Defaults to 'post_tag'.
  • (bool) $append If true, don't delete existing tags, just add on. If false, replace the tags with the new tags.
Uses:
Returns:
  • (mixed) Array of affected term IDs. WP_Error or false on failure.
Defined at:



Set the terms for a post.

Source


<?php
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_map'intval'$tags );
        
$tags array_unique$tags );
    }

    return 
wp_set_object_terms($post_id$tags$taxonomy$append);
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics