This plugin hasnt been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Customize Posts

Description

This is a feature plugin intended to implement #34923: Introduce basic content authorship in the Customizer.

The goal for this plugin is to be able to expose the editing of posts and pages in the Customizer, allowing you to edit post data and postmeta for any number of posts, and preview the changes before saving them for others to see. This plugin was birthed out of the Widget Customizer feature-as-plugin project which was merged into WordPress Core: as widgets (in 3.9) and nav menus (4.3) can now be managed in the Customizer, so too should posts and pages be editable in the Customizer as well.

Did you know that changing the featured image actually makes the change live even before you save the post? This is very surprising/unexpected behavior. The only way to truly preview a change to a featured image is to use something like Customize Posts.

Likewise, did you know that changing a page template cannot be previewed from the post editor? When you change the selected page template, the change will not show up when you preview the page (see #11049). However, in Customize Posts you can preview changes to the page template just by changing the dropdown selection, and then you can see what your page would look like with the new template after the preview refreshes.

Most other changes to metaboxes containing data that gets saved to custom fields (postmeta) also get written when clicking the Preview button. The Customize Posts plugin provides a framework to edit postmeta in the Customizer with a live preview of the changes. (Fixing this underlying issue of incorrectly persisting postmeta when doing a preview is captured in #20299.)

As much as possible, the previewing of changes in Customize Posts utilizes the selective refresh capabilities introduced in WordPress 4.5. Not only does this mean it is faster to preview changes to posts and postmeta, but it also allows you to shift-click on an element to focus on the corresponding control in the Customizer pane. For example you can shift-click on the post title in the preview to focus on the post title control’s input field, or shift-click on a featured image to focus on the control’s button to open the media library.

Development of this plugin is done on GitHub. Pull requests welcome. Please see issues reported there before going to the plugin forum.

(This Customize Posts plugin is not to be confused with 10up’s Post Customizer.)

Demo Videos

The following are listed in reverse chronological order. The first, more recent videos, show more polish.

[2016-04-28] New features in 0.5.0.

[2016-03-28] Previewing post from Post Edit screen.

[2016-03-05] Opening a draft post in the Customizer to preview title wrapping.

[2016-03-04] Demo featuring the WP visual rich text editor (TinyMCE), including the insertion of images from the media library. Post content can be edited in the Customizer and previewed in multiple contexts. For example, this allows you to preview how a Read More tag will appear when the post appears on a post list page, and you can navigate to the single post to continue previewing subsequent paragraphs. You can expand the editor into a full-screen mode to focus on writing and then quickly preview the changes on the site by toggling the editor. You can make changes to as many posts as you want, but none of the changes will go live until you hit Save & Publish: everything is previewed so there is no “save and surprise”.

[2016-03-03] Demonstration of integration with Customize Setting Validation (#34893) to gracefully handle failures to save due to post locking and concurrent user editing:

[2016-03-01] Demonstration of hooking into edit post links so that they actually work in the Customizer and expand the section to edit the given post (as opposed to the link doing nothing at all when clicked), as well as shift-clicking on the title and content (needs better discovery UI, see #27403):

Screenshots

[0.7.0] Select2 dropdown in a post type's panel allows all posts of that type to be searched, including trashes. Selecting a post here causes its section to be added and expanded, with the preview then navigating to the URL for that post.

[0.7.0] Post status control is now accompanied by a post date control. A Move to Trash link also appears with the status control.

[0.7.0] Selecting a future date switches status form published to scheduled, and a countdown for when the post will be scheduled is available along with the timezone information.

[0.7.0] Clicking the date reset link causes the setting's date to be emptied, with the control's inputs then receiving the current date/time as placeholders which update each minute to correspond to the current date/time.

[0.8.0] Integration with dropdown-pages controls. Buttons to add and edit posts appear next to the page on front and page for posts controls.

[0.8.0] Edit post button appears in nav menu items that link to a post or page.

[0.8.7] – [2017-08-03]

Fixed: Prevent post field partials from erroneously selecting nested post placements, prevent edit shortcuts from being duplicated, and ensure partials get created for all posts displayed. See #355, #356.

[0.8.1] – 2016-09-23

[0.8.0] – 2016-09-22

Added:

Add ability to edit and create pages from dropdown-pages controls, such as the controls for page on front and page for posts. Adds startEditPageFlow and startAddPageFlow methods from the Customize Object Selector plugin. See #271 and PRs #272, #284, #285.

Allow page/post stubs created via nav menus in 4.7-alpha to also be edited like any other page. See #253 and PR #287.

For nav menu items linking to a post/page, add a edit button that appears in the nav menu item control next to the original link. Clicking edit will expand the section for that post/page, and collapsing the section will return focus to the button in the nav menu item control. See #147 and PR #288.

Sync post/page changes to available nav menu items and nav menu item controls, ensuring titles are consistent in available item lists and in the nav menu item control’s title, label placeholder, and original link, and in the nav menu item setting’s original_title property. If a nav menu item lacks its own title and inherits from original_title, post/page changes will now trigger nav menu selective refresh updates. See #156 and PR #288, #289.

Sync pages additions, changes, and removals to all dropdown-pages controls, in particular to the page on front and page for posts controls in the static front page section. See #153. PRs #190, #270, #275, #276.

Add previewing of title changes for pages listed by wp_list_pages(). PR #256.

Implement support for all of the WP_Query query vars, including post meta queries, ensuring results have posts’ customized state applied as expected. This is a big improvement to ensure customized posts and postmeta will appear the same before or after saving the customized state. Previously, previewing WP_Query results was very limited and often not accurate. As part of this, get_posts() and any queries made with suppress_filters on will be overridden to force filters to apply. See #246 and PR #248.

Add support to WP_Customize_Postmeta_Setting for representing non-single postmeta. Such settings are instantiated with a true single arg and they require an array value. The customize_sanitize_{$setting_id} filter will apply to each array item separately, as will the sanitize_meta() call. PR #248.

Ensure that static front page constructs get registered even without any pages yet created. Add active callback to the static front page section so that it will appear as soon as a published page exists (either via adding a new page from the Pages panel or via a nav menu item page stub in WP 4.7-alpha). See #252 and PR #254.

Refactor editor control to be reusable for not just post content but also custom fields (postmeta). See PRs #216, #269.

Ensure that the results of get_pages() has the customized state applied. This enables support for wp_dropdown_pages() (and thus the post parent control). See #241 and PR #250.

Prevent the same page from being selected as both the page for posts and the page on front. PR #270.

Improve support for page for posts by hiding page template and content since not displayed. Show notice that the page for posts is being edited. See #228, #277 and PR #278.

Allow posts component to be filtered out to be disabled like other components (widgets and nav_menus). See #132 with PRs #219 and #258.

Disable edit-post-links module in customize-direct-manipulation plugin so that edit links in the preview will continue to work in Customize Posts. PR #234.

Let Customize link in admin bar deep link on the post section when on a singular template. See #105 and PR #236.

Use non-minified scripts and styles if plugin installed via git (submodule), eliminating the need to add SCRIPT_DEBUG or do a build. PR #249.

[0.7.0] – 2016-08-06

Added:

Introduce Select2 dropdown in a post type’s panel for searching for any post to load, even if it is not shown in the preview. Selecting a post adds its section to the Customizer and expands it while also navigating to the post’s URL in the preview. Trashed posts are also listed, and selecting a trashed post will load its post data into the Customizer in its untrashed state (restoring its original status and slug) so that upon save it will be be untrashed. (#196, #199)

Add control for post date, including synchronization with publish/future status for when date is in future. Control includes timezone information and countdown for when schedule publish will happen. Also includes reset link to leave the date empty so that it will default to the current date/time when it is published. (#56, #202)

Add initial support for meta queries when the Customizer state includes changes to postmeta. (#174, #191, #197, #193)

Allow post field control labels to be defined in register_post_type() so that the names can be repurposed to be appropriate to the custom post type. (#195)

Add low-fidelity live JS-applied previews to post title changes while waiting for high-fidelity PHP-applied selective refresh requests to response. (#43)

Fixed:

Ensure title is focused and selected when creating a new post. (#209, #208, #206)

Make sure that posts are loaded for any post sections/controls that are autofocused. (#204, #205)

Speed up performance by registering post/postmeta settings and partials only as they are needed (just in time), introducing a new ensurePosts API call to fetch the settings over Ajax and create the relevant section. (#201)

0.6.0 – 2016-06-02

Added:

Add the ability to create new posts and pages in the Customizer. Created posts get auto-draft status in the DB so they will be garbage-collected if the Customizer is never saved. A new view link appears in the post section allowing a newly-created post to be navigated to easily without having to find the created post linked to in the preview. (Issues #48, #50, PR #134)

Add post slug control, wherein changes do not cause the preview to refresh by default since there is nothing to see (Issue #63, PR #148)

Posts data as saved will now be synced back into the Customizer interface, ensuring that if a post slug gets the infamous -2 added, you’ll see that in the Control. Likewise, if a wp_insert_post_data filter or content_save_pre changes your data in some way, these will be shown in the post’s Customizer controls upon saving.

0.5.0 – 2016-04-27

Support for postmeta, including a framework for registering postmeta types. (Issues #1, PR #89)

Page template control and preview, with sync from Customizer post preview back to post edit screen. (Issue #85, PR #89)

Featured image control, with sync from Customizer post preview back to post edit screen. Changes to the featured image can now be previewed, where normally this is not possible in WordPress. Improved featured image selection on edit post screen to not update featured image in place, instead waiting until the post is Saved until updating the featured image postmeta. The featured image can be set from the post edit screen and then previewed in the Customizer via the post Preview Changes button: the featured image can be further changed in the Customizer post preview, with changes synced back to the post edit screen when the Customizer post preview is exited. (Issue #57, PR #102)

Author control and preview, with sync from Customizer post preview back to post edit screen (Issue #62, PRs #89 #92)

Excerpt control and preview, with sync from Customizer post preview back to post edit screen (Issue #60, PR #91)

Comment status control and preview, with sync from Customizer post preview back to post edit screen (Issues #61, PR #100)

Ping status control and preview, with sync from Customizer post preview back to post edit screen (Issue #64, PR #100)

Improve PHPUnit test coverage to 98%.

Note: Selective refresh support was specifically tested with Twenty Fifteen and Twenty Sixteen. See #103 for a way for themes to configure how they represent the various post fields in template parts.

Improve compatibility with Customize Widgets Plus (PR #83). See also https://github.com/xwp/wp-customize-widgets-plus/pull/46 for a fix in the Customizer post preview.

Export post/postmeta settings during selective refresh requests so that new posts added will appear in the panel, such as when adding the number of posts to show in the Recent Posts widget. (Issue #97, PR #99)