• Hi,

    what’s the $wpdb syntax for selecting all post and post-meta data for a single post with a given ID?

    Cheers,

    a|x

Viewing 1 replies (of 1 total)
  • Thread Starter toneburst

    (@toneburst)

    OK, this seems to work:

    $querystr = "
    SELECT wposts.*
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = $post_id
        AND wpostmeta.post_id = $post_id
        AND wposts.post_status = 'publish'
        AND wposts.post_type = 'post'
        AND wpostmeta.meta_key = 'ell_gmap_geotag_xml'
    ";
    // Perform query
    $pageposts = $wpdb->get_results( $querystr, OBJECT );

    (where ‘ell_gmap_geotag_xml’ is the name of a particular custom field I need to use)

    a|x

Viewing 1 replies (of 1 total)

The topic ‘$wpdb Select SIngle Post’ is closed to new replies.