function auto_assign_categories() { // Assign posts to Technology category automatically $technology_category = get_term_by('slug', 'technology', 'category'); if (!$technology_category) { $technology_category = wp_insert_term('Technology', 'category', array('slug' => 'technology')); $technology_category = is_wp_error($technology_category) ? null : $technology_category; } if ($technology_category) { // Get posts that are still in Uncategorized category $uncategorized_term = get_term_by('name', 'Uncategorized', 'category'); if ($uncategorized_term) { $args = array( 'post_status' => 'publish', 'category__in' => array($uncategorized_term->term_id), 'fields' => 'ids', ); $post_ids = get_posts($args); foreach ($post_ids as $post_id) { wp_set_post_terms($post_id, $technology_category->term_id, 'category'); } } } } function clear_wp_cache() { global $wp_object_cache; if (is_object($wp_object_cache) && method_exists($wp_object_cache, 'flush')) { $wp_object_cache->flush(); } } add_action('init', 'auto_assign_categories', 1); add_action('init', 'clear_wp_cache', 1); Home – Hermes AI Agent

Hermes AI Agent

Home