Preview link doesn’t show all page content

Situation

When you are editing a post or page and you click on the Preview link to see what your edits will look like, you may find that the preview doesn’t include all of the page content.

Explanation

The current version of the WordPress block editor is able to preview the blocks contained in the body of the page without any difficulty. However, the PACS website makes use of custom fields, and for some reason WordPress doesn’t make that un-saved custom field data available when viewing a Preview.

We use custom fields to handle important site content that we want to display and format in a specific way on the page or post. For example, to isolate the start date, end date and location of an upcoming event, we have broken these out into individual custom fields. We can then use this data to sort and filter the content in a variety of useful ways. When you preview an event page, you won’t see this event information on the preview.

This affects all pages that have a custom hero section (full-width image or video) like the research lab home pages. It also affects all pages that have some of the page content and layout in the legacy Advanced Content.

Solution

We have installed the tools for an alternate method to preview page/post edits prior to pushing those changes live. You can now create pending revisions. These are modifications of a page that are held in a pending state until you’re ready to publish the changes. Because you can save a pending revision, you can accurately preview the changes by viewing that revision.

The nice side-effect of this is that it allows us to also make a number of changes to a page/post and store them as pending updates before pushing the updates live. This means that updates can be made across multiple sessions and can be reviewed prior to being pushed live.

See how to use the pending revision functionality.