Title: Proper Nested Lists
Last modified: August 22, 2016

---

# Proper Nested Lists

 *  [Puck](https://wordpress.org/support/users/puck/)
 * (@puck)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/proper-nested-lists/)
 * This plugin isn’t properly nesting lists, and it’s messing up a CSS “counter”
   I’m trying to use to reformat the numbering so sublinks are numbered “1.1”, “
   1.2”, etc.
 * This is what the plugin is outputting:
 *     ```
       <ol><li><a href="#Link1">Link1</a></li>
           <ol><li><a href="#SubLink1">SubLink1</a></li>
               <li><a href="#SubLink2">SubLink2</a></li>
               <li><a href="#SubLink3">SubLink3</a></li>
           </ol>
       <li><a href="#Link2">Link2</a></li>
       ```
   
 * Proper nested HTML lists ([W3 Wiki Page detailing this here](http://www.w3.org/wiki/HTML_lists#Nesting_lists))
   should be inside the List Item that’s their parent, like this:
 *     ```
       <ol><li><a href="#Link1">Link1</a>
           <ol><li><a href="#SubLink1">SubLink1</a></li>
               <li><a href="#SubLink2">SubLink2</a></li>
               <li><a href="#SubLink3">SubLink3</a></li>
           </ol></li>
       <li><a href="#Link2">Link2</a></li>
       ```
   
 * Any chance you can get the output working this way?
    [https://wordpress.org/plugins/better-anchor-links/](https://wordpress.org/plugins/better-anchor-links/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Puck](https://wordpress.org/support/users/puck/)
 * (@puck)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/proper-nested-lists/#post-5527964)
 * Update: I’ve fixed it myself!
 *     ```
       function output_content_links(){
                               $info = "";
                               if ($this->options['is_numbering']) {$seznam="ol";} else {$seznam="ul";}
                               if(count($this->links) >= 1){
                                       $title = __($this->options['displayTitle'],'mwmall');
                                       $info = '<div class="mwm-aal-container">';
                                       $info.= "<a class='mwm-aal-item' name='Content-bal-title'></a><div class='mwm-aal-title'>$title</div>
                                       foreach ($this->links as $val) {
                                               if ($this->options['is_indent']) {
                                                       if(empty($minule)) {
                                                               $minule = $val[1];
                                                               $prvni = $val[1];
                                                               $ind = --$prvni;
                                                       }else{$ind = $val[1]-$minule;}
                                                       while ($ind > 0) {$info .='<'.$seznam.'>'; $ind-- ;}
                                                       while ($ind < 0) {$info .='</'.$seznam.'>'; $ind++ ;}
                                                       $minule = $val[1];
                                               }
                                               $urlval = urlencode($this->toAscii(strip_tags($val[2])));
                                               $info.='<li><a href="#'.$urlval.'">'.strip_tags($val[2]).'</a>';
                                       }
                   if ($this->options['is_indent']) {
                       $ind = (++$prvni)-$minule;
                                       while ($ind < 0) {$info .='</li></'.$seznam.'>'; $ind++ ;}
                               }
                               $info .= '</div>';
                               }
                               return $info;
                       }
       ```
   
 * This is my new “function output_content_links”.
 * It removes the top-level list container as this was also causing problems with
   my ordering and all that list ever contained was other lists and no list-items.

Viewing 1 replies (of 1 total)

The topic ‘Proper Nested Lists’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/better-anchor-links_f1f1f1.svg)
 * [Better Anchor Links](https://wordpress.org/plugins/better-anchor-links/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/better-anchor-links/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/better-anchor-links/)
 * [Active Topics](https://wordpress.org/support/plugin/better-anchor-links/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/better-anchor-links/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/better-anchor-links/reviews/)

## Tags

 * [nested links](https://wordpress.org/support/topic-tag/nested-links/)

 * 1 reply
 * 1 participant
 * Last reply from: [Puck](https://wordpress.org/support/users/puck/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/proper-nested-lists/#post-5527964)
 * Status: not resolved