WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Query Changes? (2 posts)

  1. yas
    Member
    Posted 8 years ago #

    Does anyone know if WordPress 2.0 changes the $wpdb class or the way that queries are sent? This query works for WP1.5 but returns 'false' under WP2:

    $request = "SELECT post_id FROM $wpdb->postmeta LEFT OUTER JOIN $wpdb->posts ON ID = post_id WHERE post_status = 'publish' AND meta_key = 'featuretitle' AND post_id != '$exclude' ORDER BY rand() LIMIT $display";

    $posts = $wpdb->get_results($request);

  2. yas
    Member
    Posted 8 years ago #

    Scratch that, found the problem.

    The issue stems from the fact that my plugin requires $post_id to be set so it can write the correct info to the database. When you're first creating a post, this value hasn't been set and won't be set until write_post() has been called. I guess my plugin is being called before that happens, so the wrong data is getting written (post_id defaulting to zero).

    Any developers out there know how to approach this issue? Is there a way to get $post_id in the Write Post page if the post is brand new?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.