functions – What is the text that appears beside the page titles in the list of pages in the WP admin?

Question

It’s called post state, but not to be confused with post status (publish, draft, etc.) (although the state can of course contain the post status), and the core WordPress function which adds the post states such as the Privacy Policy Page to the posts (Posts, Pages, CPTs) list table is _post_states(), but the states are retrieved using get_post_states() which fires the display_post_states filter that you can use to add your own post states.

So for example, this adds a Foo State to the post where the ID is 123:

add_filter( 'display_post_states', 'my_post_states', 10, 2 );
function my_post_states( $post_states, $post ) {
    if ( 123 === $post->ID ) {
        $post_states['foo_state'] = 'Foo State';
    }

    return $post_states;
}

0
Flux 1 month 2021-08-17T22:13:30-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse