2

I want to remove post status from post title. E.g Currently on listing page post title comes like "Hello World - Draft" or "ABC - Completed" I don't want - Draft or any other post status.

Note* : I have renamed published status to Completed status

1 Answer 1

2

Try the following:

add_filter('display_post_states', '__return_false');

The function responsible for printing the post state on the post list table is:

_post_states()

Located in wp-admin/includes/template.php.

The following logic determines whether the state will be printed:

/**
 * Filter the default post display states used in the posts list table.
 *
 * @since 2.8.0
 *
 * @param array   $post_states An array of post display states.
 * @param WP_Post $post        The current post object.
 */
$post_states = apply_filters( 'display_post_states', $post_states, $post );

if ( ! empty($post_states) ) {
    $state_count = count($post_states);
    $i = 0;
    echo ' — ';
    foreach ( $post_states as $state ) {
        ++$i;
        ( $i == $state_count ) ? $sep = '' : $sep = ', ';
        echo "<span class='post-state'>$state$sep</span>";
    }
}

NOTE: Seeing as it is possible that other people could also use this function in their own custom list tables and or for other post types, you should check for context so you don't interfere elsewhere.

2
  • Seems more fitting here ;-) Commented Mar 9, 2016 at 11:49
  • Yeah haha... whoops :)
    – Adam
    Commented Mar 9, 2016 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.