Sage adds weird strings to WP_Query()

I’m basically creating a search function, but my query always returns empty even though the search string matches a post in my database.

And I noticed when I dumped the WP_Query, it seems like there are some weird (hashed) strings included in the actual MySQL query.

which makes me think as to why the query is failing

This doesn’t help with the issue of your search not returning any results but those characters are a way for WP to prevent SQL injection and has nothing to do with Sage.

1 Like

Not really sure how you’re looping WP_Query in this context but I’d probably just use get_posts() depending on the situation.

 * Search for posts containing the specified keyword.
 * @param  string $value
 * @return array
public function search($value = '')
    if (empty($value)) {
        return [];

    $value = sanitize_text_field($value);

    $results = collect(
            'post_type' => ['post'],
            'post_status' => 'publish',
            'posts_per_page' => 25,
            's' => $value,

    if ($results->isEmpty()) {
        return [];

    return [
        'count' => $results->count(),
        'items' => $results->take(5)->map(function ($post) {
            return [
                'id' => $post->ID,
                'title' => get_the_title($post->ID),
                'url' => get_permalink($post->ID),
                'category' => collect(
1 Like

I’m using the

array_map( function ($post) {
}, $query->posts)