search-extras.php 1018 Bytes
<?php



add_action( 'add_attachment', 'add_attachment_mime_type' );
function add_attachment_mime_type( $attachment_id ){
   $post =  get_post( $attachment_id );
   $post_mime_type = explode(".", $post->_wp_attached_file);
   update_post_meta( $attachment_id, 'file_type', end($post_mime_type) );

}

function exclude_post( $query ) {
    if (  $query->is_main_query() ) {


        $meta_query = $query->get('meta_query') ? $query->get('meta_query') : array();

        // append yours
        $meta_query[] = array(
            'key' => 'exclude_from_search', // please make sure that key is correct
            'value' => '1',
            'compare' => '!=' // you can also try 'NOT EXISTS' comparison
        );

        $query->set('meta_query', $meta_query);

    }
}
add_action( 'pre_get_posts', 'exclude_post' );
 



// apply tags to attachments 
function wptp_add_tags_to_attachments() {
	register_taxonomy_for_object_type( 'post_tag', 'attachment' );
}
add_action( 'init' , 'wptp_add_tags_to_attachments' );