manadeprived
Member
Posted 11 months ago #
I have a custom theme made for my site yet search for images in the media library does not work. I believe this is theme specific because if I apply the default WordPress theme (Twenty Eleven), search works as intended.
My question is where can I find the part of the code that deals with this specific function?
Thanks!
Start by removing any javascript or jQuery calls (or deregisters) in the theme.
manadeprived
Member
Posted 11 months ago #
esmi, you are awesome.
I was able to narrow the bug to one line.
/* LIMIT SEARCH RESULTS */
function vibeExcludePages($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','vibeExcludePages'); <--Deleting this line makes it work.
Not entirely sure what this line actually does though, so I am afraid I am breaking something if I do this.
manadeprived
Member
Posted 11 months ago #
Hmmm, searching up the code on Google seems to show that this is code used to exclude pages from the search. Somehow it affects my Media Library searches too.
Try changing it to:
if( !is_admin() ) add_filter('pre_get_posts','vibeExcludePages');
manadeprived
Member
Posted 11 months ago #
esmi,
If I understand your code correctly, would that make it so that search only works properly if you an administrator? I have editors that I wish for search to work for them as well.
Thanks!
No - the change I made ensures that the code won't be loaded into the admin area.
Alkorr
Member
Posted 10 months ago #
Hi esmi! I just posted on this thread:
http://wordpress.org/support/topic/cant-search-in-media-library
Are the two solutions the same ones? Because I don't get where to put either you code or the other one... Damn, I wish I understood PHP better...
Thanks for your help!
Alkorr
Member
Posted 10 months ago #
Me again, I found out eventually.
Thanks Esmi, you rock, as always! :)