This adds support for previewing both new posts and pages (drafts), and editing published posts and pages.
I'm being a little clever, by not using the API to fetch this data, and instead relying on the preloaded data in the page to be the correct data I want. And it is, since you're only getting to these pages by clicking from wp-admin, the initial page load will be for the preview data, and the global $post data in get_post_data contains the updated or draft data. 🎉
This adds support for previewing both new posts and pages (drafts), and editing published posts and pages.
I'm being a little clever, by not using the API to fetch this data, and instead relying on the preloaded data in the page to be the correct data I want. And it is, since you're only getting to these pages by clicking from wp-admin, the initial page load will be for the preview data, and the global
$post
data inget_post_data
contains the updated or draft data. 🎉