how can i query posts by current date and auto assign category based on keyword found on post title, something like if title contains 'oranges' auto assign it 'oranges' category
maybe something like this which can go to functions.php
function add_category_automatically($post_ID) {
global $wpdb,$post;
$today = getdate();
$query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] );
while ( $the_query->have_posts() ) : $the_query->the_post();
$post_title = get_the_title();
if (stripos($post_title, 'francisco')!==false) {
$cat = array(8);
wp_set_object_terms($post_ID, $cat, 'category');
}
endwhile;
}
add_action('publish_post', 'add_category_automatically');