• Hi all,
    In WP 4.2 project I want to make request on posts with condition like

    query_posts( 'post_type=artists_songs&cat='.$artistsCategory->term_id );

    But it did not returned result set I expected.
    I made some sql debugging and found then sql looks like :

    SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID
      FROM wp_posts
     WHERE 1=1  AND (
      0 = 1
    ) AND wp_posts.post_type = 'artists_songs' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private')
      GROUP BY wp_posts.ID
      ORDER BY wp_posts.post_date DESC LIMIT 0, 10

    If manually to remove 1 line
    0 = 1
    it works ok. It was strange for me why this condition was generated and how to remove it? Any ideas?

    Actually I used similar conditition I started at the beginning and it worked ok…

Viewing 1 replies (of 1 total)
  • I suspect that $artistsCategory->term_id does not contain an integer. Use print_r to see its actual contents:

    print_r('<pre>CAT:');print_r($artistsCategory->term_id);print_r('</pre>');
Viewing 1 replies (of 1 total)
  • The topic ‘sing query_posts in sql condition 0=1’ is closed to new replies.