WPDB Database Query fails (2 posts)

  1. NeXXor
    Posted 8 years ago #

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


    $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

  2. ismyrnow
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic