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_archive_title filter filters the post type archive title in WordPress. This filter hook is quite handy when you want to customize the way your post type archive titles are displayed. It’s like giving your site a little extra flair without much effort!
Description
This is a filter hook that filters the post type archive title. It consists of two parameters: one is $post_type_name, and the other is $post_type. It is used in post_type_archive_title() which displays or retrieves the title for a post type archive.
Parameters
- $post_type_name: (string) Post type ‘name’ label.
- $post_type: (string) Post type.
Live Examples
Example 1: Basic Usage
To run the hook, copy the example below.
$object_labels_name = weplugins_apply_filters( 'post_type_archive_title', $object_labels_name, $object_name ); if ( !empty( $object_labels_name ) ) { // everything has led up to this point... }
Example 2: Adding a Hook Callback
The following example shows how to add a hook callback.
// define the post_type_archive_title callback function weplugins_filter_post_type_archive_title( $object_labels_name, $object_name ) { // make filter magic happen here... return $object_labels_name; }; // add the filter add_filter( 'post_type_archive_title', 'weplugins_filter_post_type_archive_title', 10, 2 );
Example 3: Removing a Hook Callback
To remove a hook callback, use the example below.
// remove the filter remove_filter( 'post_type_archive_title', 'weplugins_filter_post_type_archive_title', 10, 2 );
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.