-
Notifications
You must be signed in to change notification settings - Fork 37
List all posts of a given post type in the section #146
Comments
As it turns out, this is pretty easy to do by just creating a add_action( 'wp_footer', function(){
if ( ! is_customize_preview() ) {
return;
}
// Trick the Customizer into thinking we're looking at all pages and services
new \WP_Query( array(
'post_type' => array( 'page', 'service' ),
'posts_per_page' => 100,
'post_status' => 'publish',
));
}); |
One last note: performing this action on |
@danielbachhuber really great tips, thanks! And you're right, we do need to be listing out all posts/pages regardless of whether they are currently displayed in the preview. With the introduction of the new View link this would be especially relevant, since you could open a post/page section in the Customizer and then click View to navigate there: Another important reason for listing all posts/pages is a drag & drop interface for changing the The unexpected ordering of the post sections that appear in the Customizer panel was also raised by @ahmadawais in #124 This has come up recently in relation to widget sidebars as well, #36922. |
I imagine we'll take a broader look at the overall UI eventually, but I'll note for now that it might be better to avoid doing a panel for posts and pages, and only show the active post section on singular views. Otherwise we'll eventually end up building the add-menu-item UI all over again... and I imagine we'll come up with a way to merge those eventually. If you can navigate the site both in the preview and in the pane, there's an experience split. In the live preview context, I imagine it would make more sense to keep most content navigation in the preview. |
@celloexpressions there needs to be multiple posts active in the Customizer at a time—multiple post sections accessible for any given previewed URL—because a post type may not have a singular view and also posts may need to be previewed in the context of a subquery where they are listed on another post's singular view. |
The key pieces to solve this issue (List all posts of a given post type in the section) are implemented now in #196. The solution is to introduce a Select2 for looking up a post to lazy-load the post/postmeta settings, create the section, and then open the section and navigate to the post in the preview (if it is not among the posts queried). Other enhancements out of scope of that PR include:
|
For smaller sites, where there are a limited number of total pages, it would be nice if a developer could easily customize this plugin to always list all posts of a given post type in the post type's section.
The text was updated successfully, but these errors were encountered: