Forums

List Pages with wpdb, exclude several not working (2 posts)

  1. meannastynaughty
    Member
    Posted 3 years ago #

    Hello,

    i'm trying to query all posts that are pages and published but NOT Page Number (ID) 21 or 153.

    My Query looks like that:

    $getcats = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' AND $wpdb->posts.ID != 21,153 AND $wpdb->posts.post_parent = '0' ORDER BY menu_order ASC ");

    The problem is: It works with either ID 21 OR ID 153, but it doesn't work with both numbers at the same time.
    How can i exclude those two IDs out of the query?

    Thanks in advance for your answers!

  2. jeffdempsey
    Member
    Posted 2 years ago #

    I am looking for the EXACT same answer. I know that with newer versions of mysql it would be <>

Topic Closed

This topic has been closed to new replies.

About this Topic