Skip to content

Fix: Settings panel not reflecting 'Sort by date' on Created Templates view#76108

Open
Mustafabharmal wants to merge 1 commit intoWordPress:trunkfrom
Mustafabharmal:fix/templates-sort-by-date-settings-panel
Open

Fix: Settings panel not reflecting 'Sort by date' on Created Templates view#76108
Mustafabharmal wants to merge 1 commit intoWordPress:trunkfrom
Mustafabharmal:fix/templates-sort-by-date-settings-panel

Conversation

@Mustafabharmal
Copy link
Contributor

What?

When navigating to Site Editor → Templates → Created (the user tab), templates are correctly sorted by date, but the Settings panel displays "Sort by: Template" instead of "Sort by: Date". The sort dropdown also doesn't offer a Date option.

Closes #75136.

Why?

wp_template is a design post type. The usePostFields hook in @wordpress/editor explicitly excludes dateField for all design post types:

! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) && dateField,

Both rendering paths for the template list (legacy router in edit-site and new router in template-list) called usePostFields({ postType: 'wp_template' }) to obtain dateField. This always returned undefined for templates, so dateField was never added to the DataViews fields array. With no registered date field, DataViews' SortFieldControl couldn't reflect view.sort.field === 'date' and fell back to the first available field ("Template").

How?

Import dateField directly from @wordpress/fields in both paths, bypassing usePostFields. Push it to the fields array when activeView === 'user' (the Created Templates tab), matching the existing getActiveViewOverridesForTab('user') sort override.

Testing instructions

  1. Ensure that “Template Activation” experiment is enabled.
  2. Open Site Editor → Templates.
  3. Click the Created tab (user-created templates).
  4. Open the Settings panel (top-right grid/list view options).
  5. Confirm Sort by: Date is selected and the Date option is available in the dropdown.
  6. Switch to the All or Theme tab and confirm Sort by: Template is shown (unchanged behaviour).

Screenshots or screencast

Before After
image image

@github-actions github-actions bot added the [Package] Edit Site /packages/edit-site label Mar 3, 2026
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: gigitux <gigitux@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Edit Site /packages/edit-site

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings panel doesn’t reflect “sort by date” when user lands on the Created Templates view

1 participant