When variable value have space between word, doesnt show any result WP_Query

I now create a widget, that return the post has same tag enter in inputbox
I use WP_Query, but i have a problem. when i enter word with space in inputbox dont return any result, but when enter word dont have space its work correctly

This is my inputbox

<input type=”text” class=”widefat” id=”<?php echo esc_attr($this->get_field_id(‘tagCategory’)) ?>”
name=”<?php echo esc_attr($this->get_field_name(‘tagCategory’)) ?>”
value=”<?php if (isset($tagCategory)) echo esc_attr($tagCategory); ?>”/></p>

This is my Query

$wpbp = new WP_Query(array(
‘post_type’ => ‘post’,
‘tag’ => $tagCategory,
‘posts_per_page’ => $numberOfPosts,
‘orderby’ => ‘id’,
‘order’ => ‘ASC’
)
);

Read more here:: When variable value have space between word, doesnt show any result WP_Query

Leave a Reply

Your email address will not be published. Required fields are marked *