0

The theme I am using inserts and styles the page title using this code. I would like to display the category name depending on whatever it is for that category.

I have tried a number of methods but none of them work inside this code. I can make the static title 'Blog Category' appear for each category but not a dynamic category title.

Any suggestions would be most welcomed !!

  <!-- Page Heading -->
        <h1 class="fl">
        <?php if ( is_front_page() ) { 
            echo(__('Let\'s talk about respect and equity', 'layeru'));
        } else if ( is_category() ) {           
           echo(__('Blog Category', 'layeru'));         
        } else if ( is_404() ) {
            echo(__('Page Not Found', 'layeru'));
        } else if ( is_search() ) {
            echo(__('Search', 'layeru'));
        } else if ( function_exists('bp_is_active') && bp_is_group_single() ) {
            echo(__('Discussion Groups', 'layeru'));
        } else if ( function_exists('bp_is_active') && bp_is_member() ) {
            echo(__('My Activity', 'layeru'));
        } else {                
            global $wp_query;
            $page_title = $wp_query->post->post_title;
            echo $page_title;
        }
        ?>
        </h1>
  • I just worked it out myself using this statement: else if ( is_category() ) { echo(__(single_cat_title(), 'layeru')); – Glen Schaefer Jul 15 '14 at 6:21
0

You can use get_queried_object to return the name of the current category page you are on

 $cc = get_queried_object();
  echo $cc->cat_name; //display the name of current category page
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.