Exciting News! Flipper Code is now WePlugins! Same commitment to WordPress Development 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 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!

Access Premium WordPress Plugins

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

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 ); 
    
Contact Us if you need customization. Visit WePlugins Contact Page for further assistance.
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.