lundi 5 octobre 2015

Set all post with X category to X post format when using XML-RPC

I came across this thread, which seems like it would work for what I'm trying to accomplish. I'm a little unclear on this code and was hoping for a hand. When a post is submitted to my wordpress site via XML-RPC integration with a specific category, I want to the post to default to a specific post format.

Do I simply change out the "aside" format for my desired format, and change 'tweet' for my desired category?

<?php

/* Plugin Name: WPSE53245 - Set Tweet category posts as Aside Plugin URI: http://http://wordpress.stackexchange.com/questions/53235 Description: Set Tweet category posts as Aside Version: 0.1 Author: Ashfame Author URI: http://ift.tt/1MUGf4G */

add_action( 'save_post', 'wpse53235_set_post_format_aside' );

function wpse53235_set_post_format_aside( $postID ) {
    if ( has_post_format( 'aside', $postID ) || !has_term( 'tweet', 'category', $postID ) )
        return;
    set_post_format( $postID, 'aside' );
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire