Single qutes search In WordPress and PHP

In WordPress

$search = html_entity_decode($searchKey, ENT_QUOTES,  'UTF-8' );
	 
$args = array('post_status'=>"publish",'posts_per_page' => $limit,'offset' => $offset, 'order' => 'DESC' ,'s' => $search, 'post_type' => Array('post', 'page', 'markets' , 'people', 'post','projects','services') );

$result = new WP_Query( $args );

In PHP

$search_val = '';
if(!empty($post['search_key'])){
	$search_val = '%' . mysql_real_escape_string($post['search_key']) . '%';

$query = "SELECT p1.ID FROM $wpdb->posts AS p1 ";
$query .= " INNER JOIN $wpdb->postmeta AS p2 ON (p1.ID = p2.post_id) WHERE 1=1  (p1.post_title LIKE '$search_val')";
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s