• I am trying to use wp_list-Categories to create an index page on all posts (they are all recipes) on a Page. That was the easy part. I also need them to expand and collapse accordion-style. Using a script from Project Seven to implement, very handy, except I have to be able to put a div around each child

      So wp_list_categories spits out this;

      <ul>
       <li>Main Category 1</li>
           <ul>
              <li>Child Category 1</li>
              <li>Child Category 2</li>
           </ul>
       <li>Main Category 2</li>
      </ul>

      But I need it to spit out:

      <ul>
       <li>Main Category 1</li>
          <div>
            <ul>
              <li>Child Category 1</li>
              <li>Child Category 2</li>
            </ul>
           </div>
       <li>Main Category 2</li>
      </ul>

      Is there any way I can make this happen?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 1. The code you want to output is invalid.

    2. You can’t insert <div></div> tags into wp-list_categories. You might want to look at building your own category listing using get_categories. Or just install a folding category list plugin.

    Thread Starter websydaisy

    (@websydaisy)

    Actually I just figured out how to do it.

    It is in wp-includes/classes.php

    In the Create HTML list of categories section, I changed

    $output .= “$indent<ul class=’children’>\n”;

    to $output .= “$indent<div><ul class=’children’>\n”;

    and

    $output .= “$indent\n”;

    to $output .= “$indent</div>\n”;

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add divs within list categories’ is closed to new replies.