bux23
7/12/2016 - 3:03 PM

WP auto set post meta

WP auto set post meta

function place_the_custom_meta_fr($servicename, $post_id) {
	
	if (in_category(array( 22, 23, 24, 25, 26, 27 ))) {
		$thePostId = get_the_ID();
		$auth = get_post($thePostId);
		$thePostAuthor = $auth->post_author;
		$theBollinoNew = '[check_if_new post_id="'.$thePostId.'"]';
		$theAuthorFoto = '[show_avatar id='.$thePostAuthor.'  avatar_size=100]';
		$theVote = '[mr_rating_result post_id="'.$thePostId.'"]';
		$theVoteSort = '[mr_rating_result show_count="false" result_type="percentage" post_id="'.$thePostId.'"]';
		
		update_post_meta($thePostId, "eg-bollino_nuovo", $theBollinoNew);
	    update_post_meta($thePostId, "eg-author-foto", $theAuthorFoto); 
	    update_post_meta($thePostId, "eg-voto", $theVote);
	    update_post_meta($thePostId, "eg-voto-sort", $theVoteSort); 
    }
}
add_action("save_post", "place_the_custom_meta_fr", 99);