Support » How-To and Troubleshooting » how to use function single_cat_title()

how to use function single_cat_title()

  • I want to show current category title

    I found this page

    <p><?php single_cat_title('Currently browsing '); ?>.</p>

    Currently browsing WordPress.

    I try this

        $page_title = __("Category Archives :",'obandes');
    	$page_title = $page_title.single_cat_title('', false);
    //ok echo Category Archives : WordPress
    	$page_title = single_cat_title($page_title, false);
    //bad echo  WordPress
    printf('<div class="h1" id="archives-title">%s</div>',esc_html($page_title));

    I am search other example.

    find twentyten category.php

    <h1 class="page-title"><?php
    	printf( __( 'Category Archives: %s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' );

    Is this only my ploblem?

    why I have not good result?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Michael


    Forum Moderator

    can you describe what your problem is?

    Sorry alchymyth

    function single_cat_title have 2 parameter.
    It is prefix and display parameter.

    the prefix parameter is not work.

    Can my explanation be understood?

    Moderator Michael


    Forum Moderator

    this is either done on purpose, but undocumented, in the core files (/wp-includes/general-template.php), or an error.

    the resp code snippet is here:

    750      if ( $display )
     751          echo $prefix . $term_name;
     752      else
     753          return $term_name;
     754  }

    so – with the display parameter ‘false’ to return a string, the prefix is ommitted.

    however, when you know this, you can simply program what you want, as you are working with strings anyway.

    I understand Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to use function single_cat_title()’ is closed to new replies.