comment cat c3 a9goriser et tagger automatiquement les messages dans wordpress

Solutions on MaxInterview for comment cat c3 a9goriser et tagger automatiquement les messages dans wordpress by the best coders in the world

showing results for - "comment cat c3 a9goriser et tagger automatiquement les messages dans wordpress"
Fabiana
25 Feb 2016
1<?php
2add_action( 'wp_insert_post', 'update_post_terms' );
3function update_post_terms( $post_id ) {
4    if ( $parent = wp_is_post_revision( $post_id ) )
5        $post_id = $parent;
6    $post = get_post( $post_id );
7    if ( $post->post_type != 'post' )
8        return;
9    // add a tag
10    wp_set_post_terms( $post_id, 'new tag', 'post_tag', true );
11    // add a category
12    $categories = wp_get_post_categories( $post_id );
13    $newcat = get_term_by( 'name', 'Some Category', 'category' ); 
14    array_push( $categories, $newcat->term_id );
15    wp_set_post_categories( $post_id, $categories );
16}
17?>
similar questions