Created
October 18, 2019 22:43
-
-
Save spacedmonkey/d9a3c066c63dff41470a2dedd2d8734d to your computer and use it in GitHub Desktop.
Get all posts for all post types in javascript.
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
wp.apiFetch( { path: '/wp/v2/types' } ).then( ( post_types ) => { | |
for ( let post_type in post_types ){ | |
let {rest_base} = post_types[post_type]; | |
wp.apiFetch( { path: '/wp/v2/' + rest_base } ).then( ( posts ) => { | |
console.log(posts); | |
}); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment