[wp-trac] [WordPress Trac] #51403: Add filter for _post_states as it outputs raw HTML
WordPress Trac
noreply at wordpress.org
Mon Sep 22 21:58:45 UTC 2025
#51403: Add filter for _post_states as it outputs raw HTML
-------------------------------------------------+-------------------------
Reporter: brandbrilliance | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: good-first-bug has-test-info has- | Focuses: template
patch |
-------------------------------------------------+-------------------------
Comment (by paulbonneau):
Hello @SirLouen @brandbrilliance,
I created a PR with an implementation attempt of what you described
@SirLouen.
The new filter can be tested by adding the code below to a test theme
functions.php or test plugin :
{{{#!php
<?php
add_filter('post_states_string', function($post_states_string, $post){
return $post_states_string .= '<span class="post-state">, Sample
state</span>';
}, 10, 2);
}}}
Nevertheless I'm not sure that a filter in _post_states function (`/wp-
admin/includes/template.php` l.2248) is necessary.
_post_states seems to be a formatting function specifically designed to
display post states in the WordPress admin post list view.
The use case described by @brandbrilliance seems already covered. One can
totally use the get_post_states function to gather post state and format
them as you want on another screen sans passer par la fonction
_post_states.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51403#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list