Forums › Forums › Search & Filter Pro › Limiting media search to just PDFs
- This topic has 5 replies, 1 voice, and was last updated 6 years, 4 months ago by Trevor.
-
Trevor(Private) June 19, 2018 at 7:06 am #180679
I think you will need to use our Edit Query Arguments filter to add an extra argument like this:
'post_mime_type' => 'application/pdf';
Anonymous(Private) June 19, 2018 at 2:53 pm #180694So this is the code block I’d be using?
function filter_function_name( $query_args, $sfid ) { //if search form ID = 225, the do something with this query if($sfid==225) { //modify $query_args here before returning it $query_args['somearg'] = 'newvalue'; } return $query_args; } add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );
Can you give me any information on how I’d apply your suggestion to this filter? Sorry, I’m not much of a coder.
Trevor(Private) June 19, 2018 at 4:06 pm #180703Yes. The ID number (225) will change to match the ID number of your form, and the code goes inside the functions.php file of your child theme folder.
You replace this:
$query_args['somearg'] = 'newvalue';
With:
$query_args['post_mime_type'] = 'application/pdf';
Anonymous(Private) June 19, 2018 at 8:45 pm #180733Trevor, I appreciate the help so far. This is the filter I tried in our functions.php file:
function filter_function_name( $query_args, $sfid ) { //if search form ID = 35922, the do something with this query if($sfid==35922) { //modify $query_args here before returning it $query_args['post_mime_type'] = 'application/pdf'; } return $query_args; } add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );
I got the ID by looking at the query string in the URL on the edit page, as well as verifying it through
data-sf-form-id="35922"
on the form itself using Chrome inspector.For our search page, we’re including posts, pages, and media (trying to only include PDFs from media). After I added this to functions.php, it actually stopped ALL search items from loading.
Any ideas?
-
AuthorPosts