WordPress.org

Ready to get started?Download WordPress

Forums

Missing argument 2 for wpdb::prepare() (3 posts)

  1. 610216
    Member
    Posted 1 year ago #

    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']);

  2. 610216
    Member
    Posted 1 year ago #

    The waining display:http://xiedexu.cn/?s=nofollow

  3. Andrew Nacin
    Lead Developer
    Posted 1 year ago #

    If you're a user: Your site is fine. If you're a plugin/theme author, please read: http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/. If you're a user, please point your plugin/theme author to that post.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.