Make WordPress Core

Opened 4 years ago

Last modified 18 months ago

#50375 new feature request

Using post_type_archive_title() does not return the right laebl

Reported by: shamai's profile shamai Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4.2
Component: General Keywords:
Focuses: Cc:

Description

This seems to return the name label of the post type.
It does not return the archives label.

Shouldn't it return the archives label?
$post_type_obj->labels->archives

Change History (2)

#1 @arpitgshah
4 years ago

Hey,

Can you please share your screenshot for what you are looking to return with this function code?

I am new with this core and finding first bug to resolve the issues and help the core of WordPress team.

Please guide me what you are looking for to resolved.

Thanks,
Arpit G Shah

#2 @mayur8991
18 months ago

 $post_type_obj = get_post_type_object( get_post_type() );
 $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );


Use it the way i mentioned
post_type_obj contain all details you can retrieve the data you need.
it contain many things like label , name , archives etc

WP_Post_Type Object
(
    [name] => post
    [label] => Posts
    [labels] => stdClass Object
        (
            [name] => Posts
            [singular_name] => Post 
            [all_items] => All Posts
            [archives] => Post Archives
            [menu_name] => Posts
            [name_admin_bar] => Post
        )
)


Note: See TracTickets for help on using tickets.