Conditional Statements in Functions.php
-
I have a snippet of code running to remove a post from a category after a specified length of time, however I would like to exclude an author from this function. I have tried a few things to accomplish this with no success. I am really unsure how to accomplish this.
Here is the code use to remove the post from a category:
function auto_cat_remove() { global $post; wp_schedule_single_event( time() + 20, 'remove_news_cat_event', array( $post->ID ) ); } function remove_news_cat_func( $post_id ) { global $wpdb; $category_id = 598; $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $post_id, $category_id ) ); } add_action( 'wp_insert_post', 'auto_cat_remove' ); add_action( 'remove_news_cat_event', 'remove_news_cat_func' );
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Conditional Statements in Functions.php’ is closed to new replies.