WordPress.org

Forums

[resolved] Category list title repeated (6 posts)

  1. gilliancs
    Member
    Posted 7 years ago #

    I've updated from 2.04 to 2.3 and now find that the title "category" is repeated in my sidebar. I've looked at the pages about list_category tags to see if the syntax is changed but can't work out what the problem is. I'm using the Sandbox K2light theme (somewhat hacked about).

    I'd be very grateful for any help: I know it must be a busy time for everyone.

    <?php /* if this is not a page */ if ( !is_page() )
    				{ ?>
    		<li class="category-links">
    			<h3><?php _e('Category', 'sandbox'); ?></h3>
    			<ul>
    		              <?php wp_list_categories('sort_column=name&hierarchical=true&hide_empty=false') ?>
    			</ul>
    		</li>
    				<?php } ?>
  2. Ivovic
    Member
    Posted 7 years ago #

    Yeah, you can lose the H3 tags there... but if you want to use H3 instead of the default H2 for the title, you'll have to do this:

    wp_list_categories('title_li=<h3>Categories</h3>');

  3. gilliancs
    Member
    Posted 7 years ago #

    Thanks for your reply. The problem is that I get a list like this:

    Category
    Categories
    Category 1
    Category 2
    Category 3 . . .

    I don't know where 'Categories' is coming from. (It's in a different style from both the Category heading-h3-and the list of categories.)

    It looks as if wp_list_categories is now returning the title of the table as well as the contents.

  4. Ivovic
    Member
    Posted 7 years ago #

    it's default output from wp_list_categories

    do like I said, and get rid of your H3 heading there, and use:

    wp_list_categories('title_li=<h3>Category</h3>');

    it's the new "improved" way ;)

  5. gilliancs
    Member
    Posted 7 years ago #

    Brilliant! Thank you very much.

    I see I needed to put the title call and the list call all in one, instead of separating them.

    And as I understand it, the title 'Categories' is output by default, unless you define a different title, or none by using ' '.

    The final code was:

    <?php if ( !is_page() )
          { ?>
    	<li class="category-links">
    	  <?php wp_list_categories('title_li=<h3>Category</h3>&sort_column=name&hierarchical=true&hide_empty=false'); ?>
    	</li>
    	<?php } ?>

    What's the best place to find an up-to-date list of tags and parameters for 2.3?

  6. Ivovic
    Member
    Posted 7 years ago #

    Most welcome.

    Yes, the Categories output is the default where no title is specified.

    You can dig these things up in the codex

Topic Closed

This topic has been closed to new replies.

About this Topic