Title: adria's Replies | WordPress.org

---

# adria

  [  ](https://wordpress.org/support/users/adria/)

 *   [Profile](https://wordpress.org/support/users/adria/)
 *   [Topics Started](https://wordpress.org/support/users/adria/topics/)
 *   [Replies Created](https://wordpress.org/support/users/adria/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/adria/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/adria/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/adria/engagements/)
 *   [Favorites](https://wordpress.org/support/users/adria/favorites/)

 Search replies:

## Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Automatically Add Posts to A Category Conditionally](https://wordpress.org/support/topic/automatically-add-posts-to-a-category-conditionally/)
 *  Thread Starter [adria](https://wordpress.org/support/users/adria/)
 * (@adria)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/automatically-add-posts-to-a-category-conditionally/#post-2221707)
 * this function will automatically add all posts to category 9547, unless it is
   also in category bundle, or if the post is by author 29 or 30.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Automatically Add Posts to A Category Conditionally](https://wordpress.org/support/topic/automatically-add-posts-to-a-category-conditionally/)
 *  Thread Starter [adria](https://wordpress.org/support/users/adria/)
 * (@adria)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/automatically-add-posts-to-a-category-conditionally/#post-2221705)
 * ok I figured it out. here is what I wanted to do, and it now works:
 *     ```
       function add_category_automatically1($post_ID) {
       	global $wpdb;
       	$postsWeWants = $wpdb->get_results("SELECT ID, post_author FROM $wpdb->posts where ID = $post_ID");
       	foreach ($postsWeWants as $postsWeWant) {
       		if(($postsWeWant->post_author != 30) && ($postsWeWant->post_author != 29) && !in_category('bundle')){
       			$cat = array(9547);
       			wp_set_object_terms($post_ID, $cat, 'category', true);
       		}
       	}
       }
       add_action('publish_post', 'add_category_automatically1');
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [exclude recent posts in a certain category](https://wordpress.org/support/topic/exclude-recent-posts-in-a-certain-category/)
 *  Thread Starter [adria](https://wordpress.org/support/users/adria/)
 * (@adria)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/exclude-recent-posts-in-a-certain-category/#post-1756498)
 * thanks, this got me what I needed. I just made two queries:
 * `numberposts=-1&cat=9129&offset=4&orderby=post_date&showposts=4`
 * and
 * `numberposts=-1&cat=-9129&orderby=post_date&showposts=6`
 * The first one gets that category I wanted, except the 4 most recent.
    The second
   one gets the rest of the categories, excluding the category that I got above.
   Thanks for your help!
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Comments not showing and same comment on every post](https://wordpress.org/support/topic/comments-not-showing-and-same-comment-on-every-post/)
 *  Thread Starter [adria](https://wordpress.org/support/users/adria/)
 * (@adria)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/comments-not-showing-and-same-comment-on-every-post/#post-1709207)
 * ok, I’ll have to try this weekend when there is less traffic. I’ll reply if it
   worked or not. Thanks
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Posts Not Visible on Home Page](https://wordpress.org/support/topic/posts-not-visible-on-home-page/)
 *  Thread Starter [adria](https://wordpress.org/support/users/adria/)
 * (@adria)
 * [19 years, 4 months ago](https://wordpress.org/support/topic/posts-not-visible-on-home-page/#post-511655)
 * I just figured out my posts show up if I switch the theme from K2 (which it was)
   to the Default Kubrick theme. Maybe this helps figure out the problem?

Viewing 5 replies - 1 through 5 (of 5 total)