The plugin function blog_search_filter
causes problems when using a WP_Query
that contains a search term. The filter overrides the post_type
field with any
even when a WordPress search wasn’t made. This means searches that are narrowed to a custom post type will include everything.
Quick example (when the plugin is enabled):
// Create a query to find pages.
$my_query = new WP_Query(array(
'post_type' => 'page',
's' => 'search term',
) );
// This will echo "any", but it should be "page".
echo $my_query->query_vars['post_type'];
One potential fix is to only override the post type when it’s set in the url:
// Replace lines 78-81 of "osd-blog-search-widget.php" with
// the following:
if ( $post_type ) {
$query->set( 'post_type', $post_type );
}
An alternative would be to include an additional hidden field on the form (like osd_blog_search
or similar) and then only change the post type when that is set to true.
Thank you!
]]>Hello, your plugin is really cool, but search is visible only for logged users. Can thi be changed? The plugin is here in right sidebar under the “vyhledávání” header. https://www.bestonline.cz/blog/
Thanks for a help ??
]]>Hi,
Thanks for the awesome plugin.
But when the search does not find any results, it gives this message here: “Sorry, but nothing matched your search criteria. Please try again with some different keywords. – See more at: https://magicaonline.com.br/?post_type=post&s=dfddfddd&x=0&y=0#sthash.Sewq58QN.dpuf”
And just below the message, there is a search box to try again with different keywords. But now this box is not the search box from the plugin. Is the theme default search. And it gives the results of all pages.
??
Maybe the page of not finding the results should be other, so people would not end up with a second search box that gives results on pages too.
Could you please let me know when this is updated? I would love to recommend this plugin to my students.
Thanks,
Guilherme.
]]>To avoid errors when there is no post type I changed line 77 to:
$post_type = array_key_exists(‘post_type’, $_GET) ? $_GET[‘post_type’] : false;
otherwise on /search I get:
<b>Notice</b>: Undefined index: post_type in <b>/Applications/MAMP/htdocs/OMH/web/app/plugins/osd-blog-search-widget/osd-blog-search-widget.php</b> on line <b>77</b>
]]>Something is causing the magnifying glass (search submit icon) to be huge and on the next line – can you give CSS code to fix? gavekalcapital.com/CMS/blog
Thnx!
]]>Hi I’m having an issue where the search bar isn’t finding the SVG image
https://www.simplayrugs.co.uk/blog/ if you could update the plugin that would be great thanks
]]>The widget work fine. However, the text next to the search box, and in the search box is English. It would be better if no text appeared. I can write search in my own language as the title of the widget.
]]>