WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP_Query compare not working (2 posts)

  1. spyrosvl
    Member
    Posted 11 months ago #

    Hello,

    I set this arguments for WP_Query

    $args = array(
        'nopaging' => false,
        'posts_per_page' => 3,
        'paged' => '1',
        'post_status' => 'publish',
        'category_name' => 'ideas',
        'orderby' => 'post_date',
        'order' => 'DESC',
        'meta_query'  => array(
          'relation' => 'AND',
          array(
            'key' => 'idea_language',
            'value' => $domkey
          ),
          array(
            'key' => 'idea_visibility',
            'value' => 8,
            'compare ' => '!=',
            'type' => 'NUMERIC'
          )
        )
      );

    but the != compare is not working.
    The query I get is:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (4) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') AND ( (wp_postmeta.meta_key = 'idea_language' AND CAST(wp_postmeta.meta_value AS CHAR) = 'eu') AND (mt1.meta_key = 'idea_visibility' AND CAST(mt1.meta_value AS SIGNED) = '8') ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 3

    Any help is really appreciated.

    Regards,
    Spyros

  2. spyrosvl
    Member
    Posted 11 months ago #

    Just realised that there was an extra space at the compare key.
    Resolved!

Reply

You must log in to post.

About this Topic