Support » Plugin: OSD Blog Search Widget » Error on results page

  • Resolved jasperspeicher

    (@jasperspeicher)


    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>

    https://wordpress.org/plugins/osd-blog-search-widget/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Now the search is showing pages as well. I have changed the function to this:

    // Add functionality to the custom search widget
    	public static function blog_search_filter($query) {
    		if ($query->is_search && !is_admin()) {
    			$post_type = array_key_exists('post_type', $_GET) ? $_GET['post_type'] : false;
    			if (!$post_type) {
    				$post_type = 'post';
    			}
    			$query->set('post_type', $post_type);
    		}
    		return $query;
    	}

    The main change in this second bugfix being the switch to “post” from “any”

    Thanks,
    Jasper

    Plugin Author osdwebdev

    (@osdwebdev)

    The plugin comes with two ways to generate the blog search form. You can use the widget, or the shortcode EX [osd_blog_search placeholder=’search terms’ class=’test classes’]

    Using either of those will render a search form that submits all of the necessary values for the plugin to work, including the post type. Are you using a different search form?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Error on results page’ is closed to new replies.