WordPress.org

Support

Support » How-To and Troubleshooting » WPDB Database Query fails

WPDB Database Query fails

  • Does anybody know why this code returns an empty array, even if there are static pages with an ID different to 0?

    Code:

    $query = "SELECT * FROM " . $wpdb->posts . " WHERE post_status='static' AND post_parent <> 0";
    $pages = $wpdb->get_results($query);

    $wpdb is global, if I do an echo $query for debugging reasons, it shows me the complete and correct MySQL-query. But $pages is always an empty array.
    This error only occurs when post_status=’static’ is included. Can anybody tell me why?

    Please help!

    greetings from Germany, Thomas

Viewing 1 replies (of 1 total)
  • ismyrnow

    @ismyrnow

    I am using a theme that used this on the options page, and it stopped working after upgrading to 2.3 (from 1.5 I think). I fixed it by changing post_status=’static’ to post_type=’page’.

    I’m not sure if it will give the same effect for you, but in my case, it returned pages like it used to.

Viewing 1 replies (of 1 total)
  • The topic ‘WPDB Database Query fails’ is closed to new replies.
Skip to toolbar