[resolved] Problem with single_cat_title after 3.0 upgrade, NOT resolved. (13 posts)

  1. DarkLaw
    Posted 5 years ago #


    I have just upgraded to version 3.0, and single_cat_title seems to have stopped working in my array, the category title won't display anymore.

    There is a [resolved] post a bit further down from this one, but it is NO help. He resolved it himself with very little details and I'm having the same problem! The original poster had said he got around the problem by using get_cat_name instead, but I'm confused and that doesn't do anything but cause other problems within my code. We are both apparently using the same theme because our code is the exact same.

    And if you couldn't tell, I'm still pretty fresh to php.

    Help!? :D Thanks!

    // enter the IDs of which categories you want to display
    $display_categories = array(3,24,7,12,174,15,41,9,8,11,25,16,72);
    foreach ($display_categories as $category) {
    $count = 0; // Set the post counter ?>
        <div class="clearfloat">
          <?php query_posts("showposts=4&cat=$category"); // Set showposts to 4 - 1 with excerpt and 3 without
    	    $wp_query->is_category = false;
    		$wp_query->is_archive = false;
    		$wp_query->is_home = true;
          <h3><a href="<?php echo get_category_link($category);?>">
    	// name of each category gets printed
    	  single_cat_title(); ?>
  2. esmi
    Forum Moderator
    Posted 5 years ago #

    There's some sloppy coding in there. Try changing:



    query_posts('posts_per_page=4&cat=' . $category);

  3. DarkLaw
    Posted 5 years ago #

    Thanks for the cleanup advice...

    but that still doesn't address my category titles. Any advice on that?

    Here's the actual page - http://www.TruthisTreason.net

    In the center-area column, it should denote the category name in <h3 above each group of articles... however, with the 3.0 upgrade, they vanished.


    Kevin Hayden

  4. frankbs
    Posted 5 years ago #

    hay que cambiar

    of $wp_query->is_category = false; to $wp_query->is_category = true;


    of <?php single_cat_title();?> to <?php printf( __('%s',''), single_cat_title('', false)); ?>

    asi queda

    <?php $display_categories = array(5);
    foreach ($display_categories as $category) { ?>
    <?php query_posts('posts_per_page=4&cat=' . $category);
    $wp_query->is_category = true;
    $wp_query->is_archive = false;
    $wp_query->is_home = true;

    <div class="postheader_right"><h2>"><?php printf( __('%s',''), single_cat_title('', false)); ?></h2></div>

  5. DarkLaw
    Posted 5 years ago #

    Thank you, that worked!


  6. denware
    Posted 5 years ago #

    Having the same problem with this code...

    <h3 class="catt-<?php echo $cp_pC; ?>"><a href="<?php echo get_category_link( $cp_pC ); ?>"><?php single_cat_title() ?> &raquo;</a></h3>

  7. jmaraujo
    Posted 5 years ago #

    Thank you, frankbs. I had the same problem and I could fix it with that modification. ;


    Muchas gracias, frankbs. También tenía el mismo problema y con esa modificación lo pude solucionar. ;)

  8. bluejpro
    Posted 5 years ago #

    DarkLaw, frankbs, and all

    I had the same problem.

    That fixed it --
    DarkLaw, frankbs y todos los

    Tuve el mismo problema.

    Eso es fijo. Gracias

  9. diksha
    Posted 5 years ago #

    Thank You! I had the same issue and it got resolved by your Method.

  10. AllyV4
    Posted 5 years ago #

    Thank you frankbs, it worked for me too :)

  11. ckj
    Posted 5 years ago #

    frankbs thank you it works but why do this happend?

  12. ywatson
    Posted 4 years ago #

    I know this post is over 4 months old, but there are still some templates out there that are non-functioning because of one little line.

    The problem arises from the file wp-includes/general-template.php where the function single_cat_title has been updated to include another requirement:

    if ( !is_category() )

    So if the template doesn't specifically tell the query it is a category, it will silently fail.

    In most cases simply calling $wp_query->is_category = true; BEFORE the function is called then the function will work as properly. If not, printf that was mentioned above will definitely force it to work because it won't "echo"/"display" the title.

  13. vaxgelli
    Posted 4 years ago #

    Hello. I used Brandford Magazine Theme for my webpage, and i have some problem with the "browse Category" on the right sidebar.

    The webpage is: http://www.sufurriadroxu.it/public/

    As you can see the Browse Category List is empty.

    Can you help me to resolve the problem?

    Thank you from Italy


Topic Closed

This topic has been closed to new replies.

About this Topic