Created
June 1, 2021 10:46
-
-
Save nextab/02b0e498c44e6a261b5631b5337cca02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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