• add_filter('posts_orderby_request', 'wpjam_search_orderby_filter');
    	function wpjam_search_orderby_filter($orderby = ''){
    		if(is_search()){
    			global $wpdb;
    			$keyword = $wpdb->prepare($_REQUEST['s']);
    			return "((CASE WHEN {$wpdb->posts}.post_title LIKE '%{$keyword}%' THEN 2 ELSE 0 END) + (CASE WHEN {$wpdb->posts}.post_content LIKE '%{$keyword}%' THEN 1 ELSE 0 END)) DESC, {$wpdb->posts}.post_modified DESC, 	{$wpdb->posts}.ID ASC";
    		}else{
    			return $orderby;
    		}
    	}

    Warning: Missing argument 2 for wpdb::prepare(),just this $keyword = $wpdb->prepare($_REQUEST['s']);

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Missing argument 2 for wpdb::prepare()’ is closed to new replies.