I'm working on a podcast website where the theme requires all podcast episode posts to be in a custom taxonomy called qtserie. The name of the particular qtserie taxonomy that these episodes should be under is called 'main_podcast'.
I have a plugin that automatically creates a post from the podcast RSS feed when an episode airs, but the plugin cannot assign custom taxonomies. How do I have the site automatically assign the qtserie taxonomy called 'podcast' to any new podcast post that is made by the plugin? I figure that I will have the plugin assign an arbitrary category to new posts, and will need to use in_category somehow, but I'm having trouble with the code.
This is the portion of the plugin code that ad
// Create the post
global $wpdb;
$post_id;
// Check if post already exists, if so - skip. First we'll look for the GUID, then at the title.
if(!empty($guid) && $guid != '') {
$query = "SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE (meta_key = 'secondline_imported_guid' AND meta_value LIKE '%$guid%')";
$guid_count = intval($wpdb->get_var($query));
} else {
$guid_count = 0;
}
if($guid_count == 0) {
if( 0 === post_exists( $post_title, "", "", $secondline_import_post_type )) {
$post_id = wp_insert_post( $post );
// Continue if the import generate errors
if ( is_wp_error( $post_id ) ) {
continue;
}
// Add GUID for each post
add_post_meta( $post_id, 'secondline_imported_guid', $guid, true );
// Import Episode Number and Season Number
if ( function_exists('secondline_themes_theme_updater')) {
if (isset($episode_number) && $episode_number !== '') {
add_post_meta( $post_id, 'secondline_themes_episode_number', $episode_number, true );
}
if (isset($season_number) && $season_number !== '') {
add_post_meta( $post_id, 'secondline_themes_season_number', $season_number, true );
}
}
// Add episode categories
if( !empty($secondline_import_category) ) {
if( $secondline_import_post_type == 'podcast' ) {
wp_set_post_terms( $post_id, $secondline_import_category, 'series', false );
} else {
wp_set_post_terms( $post_id, $secondline_import_category, 'category', false );
}
}
````