Replies
Viewing 6 posts - 1 through 6 (of 6 total)
I also found this plugin which has search capability for ‘attachment’ post types
This function worked with default wordpress search widget:
function attachment_search( $query ) { if ( $query->is_search ) { $query->set( 'post_type', array( 'post', 'attachment','mpp-gallery' ) ); $query->set( 'post_status', array( 'publish', 'inherit' ) ); } return $query; } add_filter( 'pre_get_posts', 'attachment_search' );
Gallery items are now displayed in search results. However, how can I get this to work with the default Mediapress search?
mpp_directory_gallery_search_form();
No, none of those plugins support attachment post type.
I have tried using the wordpress search widget and added this function to search attachments but attachments are still not searched or displayed:
function my_attachments_search( $query ) { if ( !is_search() ) return $query; $post_types = $query->get( 'post_type' ); if ( ! $post_types || 'post' == $post_types ) $post_types = array( 'page','post', 'attachment','mpp-gallery' ); if ( is_array( $post_types ) ) $post_types[] = 'attachment'; $query->set( 'post_type', $post_types ); return $query; } add_filter( 'pre_get_posts', 'my_attachments_search' );
Viewing 6 posts - 1 through 6 (of 6 total)