Skip to content

Conversation

@Vedanshmini26
Copy link

@Vedanshmini26 Vedanshmini26 commented Feb 8, 2026

Trac: https://core.trac.wordpress.org/ticket/63728

Problem

The WordPress Posts list table filter area had several usability and accessibility issues:

  1. No author filtering capability - Users couldn't filter posts by author directly from the list table, requiring manual URL manipulation or additional plugins
  2. Hidden filter labels - All filter dropdowns (date, category, format) had labels hidden with screen-reader-text class, making it difficult for sighted users to understand what each dropdown represented
  3. Poor semantic structure - Filters lacked proper grouping, reducing accessibility for screen reader users
  4. Single-user sites showing unnecessary filters - No conditional logic to hide author filters when only one author exists

Root Cause

The original implementation prioritized visual compactness over usability:

  • Labels were intentionally hidden to save horizontal space in the admin interface
  • No author filter existed because it was considered an edge case, despite being a common need for multi-author sites
  • The lack of semantic HTML grouping (fieldset/legend) meant screen readers couldn't properly announce the filter group context
  • No conditional rendering logic existed to optimize the UI for single vs multi-author sites

Solution

1. Added Author Filter Dropdown

  • Created new authors_dropdown() method in WP_Posts_List_Table class
  • Conditionally displays only when:
    • Post type supports authors
    • Site has 2 or more authors with published posts
  • Uses optimized query with has_published_posts parameter to fetch only relevant authors
  • Includes filter hooks (disable_authors_dropdown, posts_authors_dropdown_authors) for extensibility

2. Made All Filter Labels Visible

  • Removed screen-reader-text class from date, category, and format filter labels
  • Labels now display inline before their corresponding dropdowns
  • Improved label text: simplified "Filter by post format" to just "Format" to reduce repetition

3. Added Semantic Grouping

  • Wrapped all filters in <fieldset class="filters-group"> element
  • Added <legend class="screen-reader-text">Filters</legend> for screen reader context
  • This allows screen readers to announce "Filters" group when navigating the controls

4. Enhanced CSS Styling

  • Added styles to properly align labels with dropdowns using float: left
  • Set font-weight: 600 on labels for better visibility
  • Adjusted line-height: 2.16666667 to vertically align with select elements
  • Proper spacing with labels having 8px margin and selects after labels having 12px margin

Backward Compatibility

  • All existing filter hooks remain intact
  • New filter hooks follow WordPress naming conventions
  • CSS changes are additive, not destructive
  • Existing functionality fully preserved

Testing

Tested on:

  • Single-author sites (author dropdown correctly hidden)
  • Multi-author sites (author dropdown appears with correct authors)
  • Custom post types with/without author support
  • All filter combinations work correctly

…hor filter dropdown and making all filter labels visible.
@github-actions
Copy link

github-actions bot commented Feb 8, 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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sheldorofazeroth, huzaifaalmesbah, mukesh27, joedolson.

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

@github-actions
Copy link

github-actions bot commented Feb 8, 2026

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

/**
* Displays an authors drop-down for filtering on the Posts list table.
*
* @since 6.8.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it actually 6.8 or 7.0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

// Check if there are multiple authors with published posts for this post type.
$authors = get_users(
array(
'who' => 'authors',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The who parameter was deprecated WP 5.9.0. I see below error.

Function WP_User_Query was called with an argument that is deprecated since version 5.9.0! who is deprecated. Use capability instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In thinking about this, I was realizing that this is not actually the correct data to pull for this filter. The filter shouldn't be users; it should be "people who have authored posts". Posts can be authored by people who previously had privileges, but don't any more, and this query wouldn't catch those.

This actually needs to source the data based on unique values in the post_author column for the post type.

Comment on lines +538 to +546
/**
* Filters the authors shown in the authors drop-down.
*
* @since 6.8.0
*
* @param WP_User[] $authors Array of WP_User objects.
* @param string $post_type Post type slug.
*/
$authors = apply_filters( 'posts_authors_dropdown_authors', $authors, $post_type );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this filter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see a good argument for this, since the author list can be a major performance problem on sites with large numbers of authors.

I think it would be better to filter the query arguments, however, not the result. Filtering the result means that you potentially run two author queries, where filtering the arguments only runs one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking more, I don't think this filter is relevant;; this isn't the right data to be querying.

?>
<label for="filter-by-author"><?php esc_html_e( 'Filter by author' ); ?></label>
<select name="author" id="filter-by-author">
<option value="0"<?php selected( $selected_author, 0 ); ?>><?php esc_html_e( 'All authors' ); ?></option>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<option value="0"<?php selected( $selected_author, 0 ); ?>><?php esc_html_e( 'All authors' ); ?></option>
<option value="0"<?php selected( $selected_author, 0 ); ?>><?php _e( 'All authors' ); ?></option>

@mukeshpanchal27
Copy link
Member

@Vedanshmini26 Left some questions/suggestions

@joedolson
Copy link
Contributor

To be thorough, this should also handle visible labels in the media library. These are being added in #23652 in the modal, but the list view would be better handled in combination with this ticket.

Copy link
Contributor

@joedolson joedolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to need to query a different type of data for author filters. Querying users isn't the data we're trying to identify; it's "people who wrote posts". We don't need to list users who have never written a post, and we do need to capture people who have written posts, but are no longer privileged.

This will also need some CSS work to style the visible labels.

// Check if there are multiple authors with published posts for this post type.
$authors = get_users(
array(
'who' => 'authors',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In thinking about this, I was realizing that this is not actually the correct data to pull for this filter. The filter shouldn't be users; it should be "people who have authored posts". Posts can be authored by people who previously had privileges, but don't any more, and this query wouldn't catch those.

This actually needs to source the data based on unique values in the post_author column for the post type.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants