Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use post_type_archive_title filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
June 28, 2023
5 minutes read

post_type_archive_title filter

Filters the post type archive title.

apply_filters( 'post_type_archive_title', string $post_type_name, string $post_type )

Description

This is filter hook , its filter the post type archive title.
Its consists of two parameters, one is $post_type_name, second is $post_type .

It is used in post_type_archive_title() which display or retrieve title for a post type archive.

Parameters

  • $post_type_name : (string) Post type ‘name’ label.
  • $post_type : (string) Post type.

Live Example

To run the hook, copy the example below.

$object_labels_name = apply_filters( 'post_type_archive_title', $object_labels_name, $object_name ); 
                         
if ( !empty( $object_labels_name ) ) { 
                         
   // everything has led up to this point... 
                         
} 
  
  

The following example is for adding a hook callback.

// define the post_type_archive_title callback 
function 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', 'filter_post_type_archive_title', 10, 2 );

To remove a hook callback, use the example below.

// remove the filter 
remove_filter( 'post_type_archive_title', 'filter_post_type_archive_title', 10, 2 ); 
Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

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.