This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
post_type_labels_post_type filter
The dynamic portion of the hook name, $post_type, refers to the post type slug.
apply_filters( "post_type_labels_{$post_type}", object $labels )
Description
This is a filter hook that filters the labels of a specific post type. It includes the following hook names:
- post_type_labels_post
- post_type_labels_page
- post_type_labels_attachment
Parameters
- $labels: (object) Object with labels for the post type as member variables.
Live Examples
Example 1: Running the Filter Hook
To run the hook, copy the example below.
$labels = apply_filters( 'post_type_labels_{$post_type}', $labels ); if ( !empty( $labels ) ) { // everything has led up to this point... }
Example 2: Adding a Hook Callback
The following example is for adding a hook callback.
// define the post_type_labels_<post_type> callback function weplugins_filter_post_type_labels_post_type( $labels ) { // make filter magic happen here... return $labels; }; // add the filter add_filter( "post_type_labels_{$post_type}", 'weplugins_filter_post_type_labels_post_type', 10, 1 );
Example 3: Removing a Hook Callback
To remove a hook callback, use the example below.
// remove the filter remove_filter( "post_type_labels_{$post_type}", 'weplugins_filter_post_type_labels_post_type', 10, 1 );
Contact Us
If you need customization, feel free to Contact Us.
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.