• Hello,
    I have a group of data saved in post meta. One of the meta key is “project_id”, if a post meta has this key, that means this post include a project.

    Now I want to get all post that with the meta key of “project_id”, so that I can make a loop for it.

    I tried this

    $meta_key = 'project_id';
    return $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key));

    It returns nothing.
    Please help! Thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to get all posts with a meta key?’ is closed to new replies.