foreach argument to get specific file types getting too many returns

You can add ‘post_mime_type’ => ‘…’ to your $args, as in: $mime_types = array (‘audio’, ‘application’) ; $args = array ( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘post_mime_type’ => $mime_types, ) ; $query = new WP_Query ($args) ; See Mime-Type Parameters for more info. It’s not documented very well but the mime-types you set can … Read more

Add a new tag based on the category name in the publish event

You have to add the true parameter to the wp_set_post_tags() function. Tested and works, the corrected code: add_filter(‘wp_insert_post’, ‘add_cat_to_tags’, 10, 3 ); function add_cat_to_tags( $post_ID, $post, $update ) { $tags = array(); $cats = get_the_category( $post_ID ); foreach ( $cats as $cat ) { $tags[] .= $cat->name; } // overwrites any existing tags!! wp_set_post_tags( $post_ID, … Read more