I'm currently running Wordpress on version 4.6.1 and I'm attempting to search for posts that contains the character
- (hyphen). However, the search parameter is taking my hyphen for a negation.
From the WP_Query documentation:
Prepending a term with a hyphen will exclude posts matching that term. Eg, 'pillow -sofa' will return posts containing 'pillow' but not 'sofa' (available since Version 4.4).
Here's my query:
$query = new WP_Query(array( 'post_type' => array('product', 'product_variation'), 's' => '-', 'posts_per_page' => 36 ));
I've tried to escape the hyphen by doing:
's' => '\-'
However, the result stays the same (
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title NOT LIKE '%%') AND (wp_posts.post_excerpt NOT LIKE '%%') AND (wp_posts.post_content NOT LIKE '%%'))) AND (wp_posts.post_password = '') AND wp_posts.post_type IN ('product', 'product_variation') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled') ORDER BY wp_posts.post_date DESC LIMIT 0, 36