[wp-trac] [WordPress Trac] #19958: Allow custom post types as "home" and get_posts() to return results for more than one post type

WordPress Trac noreply at wordpress.org
Mon Aug 24 12:20:55 UTC 2020


#19958: Allow custom post types as "home" and get_posts() to return results for
more than one post type
-----------------------------------------+-----------------------------
 Reporter:  sooskriszta                  |       Owner:  pbearne
     Type:  enhancement                  |      Status:  accepted
 Priority:  normal                       |   Milestone:
Component:  Posts, Post Types            |     Version:  trunk
 Severity:  normal                       |  Resolution:
 Keywords:  needs-testing needs-refresh  |     Focuses:  administration
-----------------------------------------+-----------------------------
Changes (by pbearne):

 * keywords:  has-patch needs-testing needs-refresh => needs-testing needs-
     refresh
 * owner:  (none) => pbearne
 * version:  3.3.1 => trunk
 * status:  new => accepted


Comment:

 This ticket got a short out in https://wptavern.com/wordpress-5-6-wish-
 list-homepage-post-type-selection-and-block-management so I am starting to
 work on it along with anybody who would like to help and let's see if we
 can this in 5.6

 I have a patch with an updated UI for admin which I would like to get
 validated as the right direction

 As came back to this after 8 years I made a few other changes

 We control which post types are allowed to be used in homepage content via
 a new arg in register_post_type()
 {{{
 'show_in_home_page_list'=> true,
 }}}
 backed up by a filter post_types_allowed_on_home_page

 {{{
 $post_types_allowed_on_home_page = apply_filters(
 'post_types_allowed_on_home_page', array_keys( get_post_types( array(
 'show_in_home_page_list' => true ) ) ) );
 }}}

 If the post capability_type of "post" the I propose we allow it to be
 swapped for the post type "post" and render on the homepage

 To support this we should a new template file front-page-{post-type}.php
 and then follow the custom post type root archive-{post_type}.php =>
 home.php this would allow a theme to provide a different layout for
 content if render as home page

 If a post type other than "post" is set we should allow setting a page to
 render posts

 If the post capability_type of "page" then we add them to the list of
 pages that can set as a home along with the normal pages (I have used an
 optgroup to group them by post types) for better UI


 I have tackled the customizer UI yet or started to handle the
 settings/override the homepage

 I would like feedback on the plan and UI

 Paul

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/19958#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list