Skip to content

Fix the usage of the 'manage_posts_custom_column' hook#1069

Closed
justinmaurerdotdev wants to merge 1 commit into
Automattic:developfrom
justinmaurerdotdev:posts-list-table-column-fix
Closed

Fix the usage of the 'manage_posts_custom_column' hook#1069
justinmaurerdotdev wants to merge 1 commit into
Automattic:developfrom
justinmaurerdotdev:posts-list-table-column-fix

Conversation

@justinmaurerdotdev

Copy link
Copy Markdown
Contributor

Fixes #1068.

Description

Per the #1068 issue, there are some use cases where the 'manage_posts_custom_column' hook is used outside of The Loop. In current versions of the plugin, this scenario produces an empty column. This PR refactors the callback for that hook to use the passed $post_id instead of using the global $post variable.

Testing

You can test that nothing has broken by viewing the Posts table and checking that the Authors column displays the same as before. I'm not 100% sure of a reliable test for the edge case, besides installing a plugin like Admin Columns and running the export from the Posts table.

…ils, since some uses of the 'manage_posts_custom_column' hook don't happen inside The Loop.
@GaryJones

Copy link
Copy Markdown
Contributor

Thanks for this, @justinmaurerdotdev — it's the right fix for a still-live bug (#1068), where the Authors column reads global $post and blows up when a list table is rendered outside The Loop (Admin Columns exports and similar).

I've taken it over in #1309: your commit is cherry-picked across with authorship preserved and rebased onto current develop, so it keeps the newer data-* byline markup that had been added to the same method since you opened this. I also added a regression test that renders the column from a post ID with no global $post set (it fails without your fix and passes with it).

Closing in favour of #1309. Credit for the fix is yours — thank you.

@GaryJones GaryJones closed this Jun 22, 2026
@GaryJones GaryJones removed this from the 4.1.0 milestone Jun 22, 2026
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.

List table $post is null in exports

2 participants