WordPress.org

Support

Support » Plugins and Hacks » Hacks » sql with relationship between wp_post and wp_postmeta

sql with relationship between wp_post and wp_postmeta

Viewing 3 replies - 1 through 3 (of 3 total)
  • Drew Jaynes

    @drewapicture

    Docs Czar

    Maybe I’m missing something, but if you’re storing the artist’s ID in the meta field, that’s what you’re going to get back from get_post_meta().

    If that’s the case, you could just wrap your get_post_meta() call in get_the_title(), e.g.

    echo get_the_title( get_post_meta( $post->ID, '_artist_id', true ) );

    Drew, Yes! you’re right!
    and when I’m in the artist page, to let people know at which Events they’re going to partecipate I do inside the loop, every cycle, another query like:

    $args = array(
    ‘post_type’=>’events’,
    ‘meta_key’ => ‘_artist_id’,
    ‘meta_value’ => $post->ID,
    );
    $sql = new WP_Query( $args );

    do you think is correct?
    thanks a lot!

    Drew Jaynes

    @drewapicture

    Docs Czar

    That should probably work, yes. And in that case you’ll have a full object to work with, not just the ID.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘sql with relationship between wp_post and wp_postmeta’ is closed to new replies.
Skip to toolbar