WordPress.org

Support

Support » Alpha/Beta » [Resolved] Query Changes?

[Resolved] Query Changes?

  • 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);

Viewing 1 replies (of 1 total)
  • 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?

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Query Changes?’ is closed to new replies.