Forums › Forums › Search & Filter Pro › Limiting media search to just PDFs
Tagged: pdf attachments relevanssi
- This topic has 12 replies, 4 voices, and was last updated 3 years, 2 months ago by Anonymous.
-
Anonymous(Private) January 12, 2021 at 3:39 pm #272526
split by @trevorsf from https://support.searchandfilter.com/forums/topic/limiting-media-search-to-just-pdfs/
Hello Trevor,
picking up on this, cause I want to do something similar: When I use the provided code for my form, the whole search only lists media. However I want to show all post types, but within media I only want to show pdfs. How to achieve this?
Trevor(Private) January 12, 2021 at 4:43 pm #272554I have referred this question to the plugin developer, Ross, for his input.
One issue with a search form such as the one you have made is that you have taxonomy fields in it. As taxonomies apply to one post type (or, they should not be shared across post types), when a taxonomy term is selected in the form includes rules, any posts from a post type that does have that taxonomy.
This type of limitation does not affect custom fields, which can be assigned to multiple post types.
Ross Moderator(Private) January 14, 2021 at 1:24 pm #272779Hi there
So the first thing that would be good to know is, before you set the mime type, do you see the results correctly?
Ie, do you get a mixture of media + post types in the results? From what I can see on your link, you get all media, and after some pages, the posts too? So this part is working ok?
If that works, then the ext step would be to see if we can specify a mime type, and have it not exclude the other posts – but I’m not sure that would be possible.
Thanks
Anonymous(Private) January 19, 2021 at 1:58 pm #273210Hello Ross,
thanks for your answer:
Before setting mime type, I see all results. First it displays all media files, after that the pages come (page 9 I think).
-> Yes, it is a mixture of media + post types.
It would be amazing, if you could help me ๐
Thanks
PhilippRoss Moderator(Private) January 21, 2021 at 5:43 pm #273541Hi Phillip
I’ve had a good go but unfortunately it’s not going to work.
Things work well until we set the mimetype, and because a regular post has no mime type it doesn’t work.
I’ve tried quite a few different options, but as soon as its set, the posts are excluded.
The only way I could think of, to do a search conditionally like that would be to use something like Advanced Custom Fields plugin.
You could add a custom field, to your media – https://www.advancedcustomfields.com/resources/adding-fields-media-attachments/
And mark all media you don’t want, with a checkbox to “exclude from search” or something similar.
Then you can use our
post meta
tab (in the search form settings), to exclude the posts with this custom field… leaving the remaining combination of images + posts.Its not ideal I’m sure, but it’s the best I could come up with.
Best
-
AuthorPosts