I want to modify dynamically the Heading1 that appears on top of the Admin List of posts. E.g. the Page heading of the Pages list.
I have exhausted all possible searches I could think of and nothing relevant came out.
Is there any function, filter, etc that allows us to modify what the content of the H1 heading of a custom post type list page would be?
I actually want to be able to add the title of a taxonomy when the list is filtered by that taxonomy.
1 Answer
When you take a look at wp-admin/edit.php
, you’ll see that this string is printed with this line:
echo esc_html( $post_type_object->labels->name );
So there is no filter to modify it in edit.php
.
There are no filters in get_post_type_object
also, so we can’t change it in there too, but…
The object for given post type is stored in global variable called $wp_post_types
, so you can modify it:
function change_page_post_type_object() {
global $wp_post_types;
$wp_post_types['page']->labels->name="Not-Pages ;)";
}
add_action( 'init', 'change_page_post_type_object' );
And that’s the result: