Repository navigation
Posts, Post Types: Allow a custom post type's latest posts on the home page - #16155
faisalahammad wants to merge 18 commits into
Conversation
# Conflicts: # src/wp-admin/options-reading.php
…evelop into ticket/19958
Co-authored-by: Adam Silverstein <adam@earthbound.com>
Co-authored-by: Adam Silverstein <adam@earthbound.com>
Co-authored-by: Adam Silverstein <adam@earthbound.com>
…update related logic.
…@covers` and `@ticket`.
…tests # Conflicts: # src/wp-admin/options-reading.php # src/wp-includes/post.php
Rewrites the home page query tests to follow core conventions and covers the `post_types_allowed_on_home_page` filter, `is_front_page()`, saving the `show_on_front` option, explicit and secondary queries, and the static front page path. Adds tests for `_reset_front_page_settings_for_post()` so trashing or deleting the front page or posts page keeps resetting those options. See #19958.
This comment has been minimized.
This comment has been minimized.
Removes the demo code added to the Twenty Twenty and Twenty Twenty-Five theme `functions.php` files. Documents the `show_in_home_page_list` argument in `register_post_type()` and adds it as a property of `WP_Post_Type` with a default of false. Points the `post_types_allowed_on_home_page` filter references at the file without a line number, and cleans up the filter docblock. See #19958.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Keeps `show_on_front` limited to `posts` and `page`, and saves the chosen post type in the `show_archive_on_front` option. Core and themes that read `show_on_front` keep working, which fixes saving the setting, `is_front_page()` on a default site, and resetting the front page and posts page when they are trashed or deleted. Only the main query on the home page is changed, so secondary queries still return posts. Restores the static page radio buttons and page dropdowns, and adds a separately labelled "Homepage post type" setting. Adds `get_home_page_post_types()` so the `post_types_allowed_on_home_page` filter is applied in one place. See #19958.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Lets a site show the latest posts of a custom post type on the home page. A post type opts in with
show_in_home_page_list, and the newpost_types_allowed_on_home_pagefilter can change the list.This builds on #10798 by @pbearne, merged with trunk, and fixes the problems found by the tests and in review.
Changes
1. The post type is stored in its own option. Core and bundled themes expect
show_on_frontto bepostsorpage. Saving a post type name there meant the setting could not be saved,is_front_page()returned false on a default site, and trashing the front page no longer reset the settings.2. Only the main home query is changed. Widgets and other secondary queries still return posts.
3. The Reading screen keeps the trunk radio buttons and page dropdowns. A separate "Homepage post type" row with its own label is shown when a post type other than
postis available. Custom post type entries are no longer listed in the static "Homepage" dropdown, because choosing one redirected to its permalink.4. New
get_home_page_post_types()applies the filter in one place. It skips pages and post types that are not registered.Screenshots
Settings > Reading with a
bookpost type that opts in.Testing instructions
'show_in_home_page_list' => trueand publish a few entries.Expected: steps 2 and 3 list only the chosen post type, with no redirect. Step 4 shows the static page as before.
Testing done
query,optionandpostgroups pass.Open points
postby default. No database version bump is included.Trac ticket: https://core.trac.wordpress.org/ticket/19958
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5, Claude Sonnet 5.5
Used for: Bug analysis, unit tests, code changes, screenshots and this description. I chose the approach and take responsibility for the result.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.