custom taxonomy - How to get post type archive category title

admin2025-01-07  5

I'm getting tired and confused so thought I would ask here before quitting for the day.

I have created a custom post type of membercontent

Under membercontent I have created the taxonomy membercontent_category

In the archive.php I was re-writing the title with:

                    ...

                    elseif ( is_post_type_archive( 'membercontent' ) ) :

                        _e( 'Member Content', 'radiate' );                      

                    elseif ( get_post_type() == 'membercontent' ) :

                        post_type_archive_title();

                    else :

                        _e( 'Archives', 'radiate' );

                    endif;

This however does not show the category archive pages...

is there a get_category_title() function?

I'm getting tired and confused so thought I would ask here before quitting for the day.

I have created a custom post type of membercontent

Under membercontent I have created the taxonomy membercontent_category

In the archive.php I was re-writing the title with:

                    ...

                    elseif ( is_post_type_archive( 'membercontent' ) ) :

                        _e( 'Member Content', 'radiate' );                      

                    elseif ( get_post_type() == 'membercontent' ) :

                        post_type_archive_title();

                    else :

                        _e( 'Archives', 'radiate' );

                    endif;

This however does not show the category archive pages...

is there a get_category_title() function?

Share Improve this question asked Apr 17, 2018 at 6:23 php-b-graderphp-b-grader 4182 gold badges7 silver badges21 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0
$category_detail=get_the_category(get_the_ID());//$post->ID
                                foreach($category_detail as $cd)
                                {
                                    $name_category=$cd->cat_name;
                                    $id_category=$cd->term_id;
                                    echo $name_category;

                                }

this code get category name and id you just put a post id

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736257366a432.html

最新回复(0)