I want to use Autoblog for more than one category

Hi There,
Probably the most important aspect of my website is aggregating rss feeds--which autoblog does for me. The trouble is I have specific categories (like social media, marketing...etc), and then I have a catch-all category called "Everything" for someone who wants to see everything. How do I make autoblog automatically post to both categories--the specific one, and the "Everything" category? Please help.

  • Jude

    Hi there @Rhodel

    Thanks for getting in touch and welcome to the community !

    Here is some code that can do this for you.

    function wpc_update_post_terms( $post_id ) {
        if ( $parent = wp_is_post_revision( $post_id ) )
            $post_id = $parent;
        $post = get_post( $post_id );
        if ( $post->post_type != 'post' )
            return;
        // add a category
        $categories = wp_get_post_categories( $post_id );
        // make sure these category names already exists. They are not created automatically.
        $newcat    = get_term_by( 'Everything', 'category' );
        array_push( $categories, $newcat->term_id );
        wp_set_post_categories( $post_id, $categories );
    }
    add_action( 'wp_insert_post', 'wpc_update_post_terms' );

    Just copy/paste the code into the functions.php file of your child theme or a site specific plugin if you use one.

    Hope that helps

    Cheers
    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.