diff --git a/includes/class-syndication-wp-rss-client.php b/includes/class-syndication-wp-rss-client.php index 3f1e7d4c03a4f42a6228e4a48b3451b921bb2db8..e403731ca2f224cae396fe1c530129f74f604408 100644 --- a/includes/class-syndication-wp-rss-client.php +++ b/includes/class-syndication-wp-rss-client.php @@ -219,7 +219,11 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client foreach ( $cats as $cat ) { // checks if term exists - if ( ! $result = get_term_by( 'name', $cat->term, 'category' ) ) { + if ( $result = get_term_by( 'name', $cat->term, 'category' ) ) { + if ( isset( $result->term_id ) ) { + $ids['cats'][] = $result->term_id; + } + } else { if ( ! $result = get_term_by( 'name', $cat->term, 'post_tag' ) ) { // creates if not $result = wp_insert_term( $cat->term, 'category' ); @@ -231,11 +235,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client $ids['tags'][] = $result->term_id; } } - } else { - if ( isset( $result->term_id ) ) { - $ids['cats'][] = $result->term_id; - } - } + } } // returns array ready for post creation