Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nextab/02b0e498c44e6a261b5631b5337cca02 to your computer and use it in GitHub Desktop.
Save nextab/02b0e498c44e6a261b5631b5337cca02 to your computer and use it in GitHub Desktop.
// get your custom posts ids as an array
$posts = get_posts(array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
)
);
//loop over each post
foreach($posts as $p){
//get the meta you need form each post
$my_post_meta = get_post_meta($p);
foreach($my_post_meta as $key => $value) {
echo 'post id: ' . $p . '<br />Key: ' . $key . ' - Value: ' . $value[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment