Forums › Forums › Search & Filter Pro › Want search to include all attachments Except Images
Tagged: attachments, images, results
- This topic has 27 replies, 2 voices, and was last updated 7 years, 9 months ago by Trevor.
-
Anonymous(Private) February 8, 2017 at 10:49 pm #89022
Awesome! Could you tell me how to do this? I’m not sure what option to select and what to put in to EXCLUDE just the images and keep the rest of the types. Any idea of what I code I need to insert in order to exclude images? Using the Post Meta section is pretty confusing. Our client is really set on having images be excluded from the results and is looking for a solution asap.
Trevor(Private) February 9, 2017 at 10:23 am #89084OK, I will need to go digging. My guess is that in the Post Meta rules you add a rule to filter on the
_wp_attachment_metadata
key. In your form, do you have theMedia
post type checked for your search (as that is containing the files you want to search)?Trevor(Private) February 13, 2017 at 11:56 am #89698Hi
I think I was going down the wrong track. what you need to do is use our Edit Query argument filter.
Or edit the query arguments directly. It rather depends how your search is setup. What Display Results method are you using?
For mine, and your, reference as we progress this support request, we will use the logic of this code snippet to modify the wp query:
$unsupported_mimes = array( 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/tiff', 'image/x-icon' ); $all_mimes = get_allowed_mime_types(); $accepted_mimes = array_diff( $all_mimes, $unsupported_mimes ); $attachment_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => $accepted_mimes, 'posts_per_page' => 20, ) );
We will not use this exactly as above, but the method.
Anonymous(Private) February 13, 2017 at 5:28 pm #89818We’re using “As an Archive” as the method.
Use a custom template for results – Is checked
Filename for custom template: searchBlog.php (basically just copied other search results page template but modified for looks)
Make searches bookmarkable – checked
Only use Ajax on the results page – checked
Scroll window to: none on all
Results container – #search-results
Pagination selector – .pagination a
Let me know if you need other settings or if you need access to our backend or files. We really need to get this solved ASAP. Thanks!
-
AuthorPosts