Title: make ordered list please
Last modified: May 7, 2022

---

# make ordered list please

 *  [almahmud](https://wordpress.org/support/users/almahmudbd/)
 * (@almahmudbd)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/make-ordered-list-please/)
 * the ACT-displayer.php file’s code can be like this for ordered list….
 *     ```
       <?php
   
       /*****************************************************************
       *
       * 
       * a hierarchical list of all posts by nested categories, post title and authors
       * © Fabio Marzocca - 2015-2017
       *
       * Frontend
       ******************************************************************/
   
       function ACT_hierarchy_indexes($atts)
       {
   
           if (!isset($_POST['order'])) {
               $_POST['order']="category";
           }
   
           if ($atts['singleuser']) {
               $atts['admin'] = "1";
           }
           ob_start();
   
           echo '<div class="ACT-wrapper">';
           if (count(explode(",", $atts['show'])) > 1) :
       ?>
   
       <form name="form1" method="post" >
               <div align="center" class="styled-select"><?php _e("Group by:", 'list-all-posts-by-authors-nested-categories-and-titles') ?> 
                 <select name="order"  id="order"  onChange=" ;this.form.submit();">
                   <?php if (!($atts['singleuser']) and strpos($atts['show'], "Author") !== false) : ?>
                   <option value="author" <?php if ($_POST['order']  == "author") {
                       echo "selected";
                                          } ?>><?php _e("Author", 'list-all-posts-by-authors-nested-categories-and-titles'); ?> </option>
                   <?php endif; ?>
                   <?php if (strpos($atts['show'], "Title") !== false) : ?>
                   <option value="title" <?php if ($_POST['order']  == "title") {
                       echo "selected";
                                         } ?>><?php _e("Title", 'list-all-posts-by-authors-nested-categories-and-titles'); ?> </option>
                   <?php endif; ?>
                       <?php if (strpos($atts['show'], "Category") !== false) : ?>
                   <option value="category" <?php if ($_POST['order']  == "category") {
                       echo "selected";
                                            } ?>><?php _e("Category", 'list-all-posts-by-authors-nested-categories-and-titles'); ?> </option>
                       <?php endif; ?>
                 </select>
               </div>
           </form>
       <?php
           endif;
   
           if (count(explode(",", $atts['show'])) == 1) :
               $_POST['order'] = strtolower($atts['show']);
           endif;
   
           if (count(explode(",", $atts['show'])) == 2 and strpos($atts['show'], "Category") === false) :
               $_POST['order'] = "author";
           endif;
   
           if ($_POST['order']  == "author") {
               ACT_byauthor($atts);
           } elseif ($_POST['order']  == "title") {
               ACT_bytitle($atts);
           } else {
               ACT_bycategory($atts);
           }
           echo "</div> <!-- ACT-wrapper -->";
           $output_string=ob_get_contents();
           ob_end_clean();
           return $output_string;
       }
   
       function ACT_bycategory($atts)
       {
           /* Start browsing categories*/
           foreach (get_categories('hide_empty=0') as $cat) :
               if (strpos($atts['exclude'], $cat->slug)!== false) :
                   continue;
               endif;
   
                   /* changes  */
   
               if (!$cat->parent) {
                    echo "<h2 id='".$cat->name."'><a href='".get_category_link($cat)."'>".$cat->name."</a></h2><ol>";
                   ACT_traverse_cat_tree( $cat->term_id, $atts);
               }
           endforeach;
       }
   
       function ACT_traverse_cat_tree($cat, $atts)
       {
           $postargs = array(
               'public'   => true,
               '_builtin' => false
           );
           $post_types = get_post_types( $postargs);
   
           array_push($post_types, 'post');
           $ordering = 'DESC';
           if ($atts['reverse-date']) {
               $ordering = 'ASC';
           }
           $args = array('category__in' => array( $cat ), 'numberposts' => -1, 'order' => $ordering, 'post_type' => $post_types);
   
           $cat_posts = get_posts( $args );
   
           if ($cat_posts) :
               $i = 0;
               foreach ($cat_posts as $post) :
                   /* exclude admin?  */
                   if (!$atts['admin']) {
                       if (is_super_admin($post->post_author)) :
                           continue;
                       endif;
                   }
                   echo '<li class="subpost">';
                  $postdate = date_i18n( get_option( 'date_format' ), strtotime($post->post_date)).' - ';
           echo ($atts['postdate'] ? $postdate : ''). '<a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a>';
                   if (!($atts['singleuser'])) :
                       echo "<span class='righttext'>[".get_the_author_meta( 'first_name', $post->post_author )." ".get_the_author_meta( 'last_name', $post->post_author )."]</span>";
                   endif;
   
                   echo '</li>';
                   $i++;
                   if ($atts['postspercategory'] > -1) :
                       if ($i >= $atts['postspercategory']) :
                           break;
                       endif;
                   endif;
               endforeach;
           endif;
           $next = get_categories('hide_empty=0&parent=' . $cat);
   
           if ($next) :
               foreach ($next as $cat) :
                   if (strpos($atts['exclude'], $cat->slug)!== false) :
                       continue;
                   endif;
   
                   /* changes  */
   
                      echo "<ol><li class='subcat'><a href='".get_category_link($cat)."'>".$cat->name."</a></li>";
                     ACT_traverse_cat_tree( $cat->term_id, $atts);
               endforeach;
           		endif;
           echo '</ol>';
       }
                   /* list ol closer  */
   
       function ACT_bytitle($atts)
       {
           $postargs = array(
               'public'   => true,
               '_builtin' => false
           );
           $post_types = get_post_types( $postargs);
   
           array_push($post_types, 'post');
   
           if ($atts['totalpoststitle'] > -1) {
               $args = array(  'posts_per_page' => -1, 'post_type' => $post_types);
           } else {
               $args = array(  'posts_per_page' => -1,
                           'orderby' => 'title' ,
                           'post_type' => $post_types,
                           'order' => 'ASC');
           }
           $articoli = get_posts($args);
           echo "<h4></h4>";
           if ($articoli) :
   
                   /* changes  */
   
               echo "<ol>";
               $i = 0;
               foreach ($articoli as $articolo) :
               /* excluded categories  */
                   if (has_category(explode(',', $atts['exclude']), $articolo->ID)) :
                       continue;
                   endif;
   
               /* include admin? */
                   if (!$atts['admin']) {
                       if (is_super_admin($articolo->post_author)) :
                           continue;
                       endif;
                   }
                   echo '<li>';
                   $postdate = date_i18n( get_option( 'date_format' ), strtotime($articolo->post_date)).' - ';
                   echo ($atts['postdate'] ? $postdate : '').'<a href="' . get_permalink( $articolo->ID ) . '">' . $articolo->post_title . '</a>';
                   if (!($atts['singleuser'])) :
                       echo "<span class='righttext'>[".get_the_author_meta( 'first_name', $articolo->post_author )." ".get_the_author_meta( 'last_name', $articolo->post_author )."]</span>";
                   else :
                       $categories = get_the_category( $articolo->ID );
                       $list_cats =null;
                       foreach ($categories as $cat) :
                           $list_cats .= $cat->name.", ";
                       endforeach;
                       $list_cats = substr($list_cats, 0, -2);
                       echo "<span class='righttext'>[".$list_cats."]</span>";
                   endif;
                   echo '</li>';
                   $i++;
                   if ($atts['totalpoststitle'] > -1) :
                       if ($i >= $atts['totalpoststitle']) :
                           break;
                       endif;
                   endif;
               endforeach;
               echo "</ol>";
   
                   /* changes  */
           endif;
       }
   
       function ACT_byauthor($atts)
       {
           $param = 'blog_id=1&orderby=nicename';
           $autori= get_users( $param );
   
           foreach ($autori as $user) :
               /*check if excluded admin */
               if (!$atts['admin']) {
                   if (is_super_admin($user->ID)) :
                       continue;
                   endif;
               }
               /* Array of WP_User objects */
               $postargs = array(
               'public'   => true,
               '_builtin' => false
                   );
                   $post_types = get_post_types( $postargs);
   
                   array_push($post_types, 'post');
   
                   $ordering = 'DESC';
               if ($atts['reverse-date']) {
                   $ordering = 'ASC';
               }
   
               $args= array(
                   'author'        =>  $user->ID,
                   'post_type'   => $post_types,
                   'posts_per_page' =>  -1,
                   'category__not_in' => get_cats_by_slug(explode(',', $atts['exclude']))
                       );
               if ($atts['postsperauthor'] == -1) {
                   array_push($args,'order',$ordering );
               }
                   $author_posts=  get_posts( $args );
               if (!$author_posts) :
                   continue;
               endif;
                   echo '<h4><a href="'.get_author_posts_url($user->ID).'">'.$user->display_name.'</a></h4>';
   
               if ($author_posts) {
                   echo '<ol>';
                   $i = 0;
                   foreach ($author_posts as $author_post) {
                       $postdate = date_i18n( get_option( 'date_format' ), strtotime($author_post->post_date)).' - ';  
                       echo '<li>';
                       echo ($atts['postdate'] ? $postdate : ''). '<a href="' . get_permalink( $author_post->ID ) . '">'.$author_post->post_title.'</a>';
                       $categories = get_the_category( $author_post->ID );
                       $list_cats =null;
                       foreach ($categories as $cat) :
                           $list_cats .= $cat->name.", ";
                       endforeach;
                       $list_cats = substr($list_cats, 0, -2);
                       echo "<span class='righttext'>[".$list_cats."]</span>";
                       echo '</li>';
                       $i++;
                       if ($atts['postsperauthor'] > -1) :
                           if ($i >= $atts['postsperauthor']) :
                               break;
                           endif;
                       endif;
                   }
               }
                   echo '</ol>';
           endforeach;
       }
   
       function get_cats_by_slug($catslugs) {
           $catids = array();
           foreach($catslugs as $slug) {
               $catids[] = get_category_by_slug($slug)->term_id; 
           }
           return $catids;
       }
   
       ?>
       ```
   
    -  This topic was modified 4 years, 1 month ago by [almahmud](https://wordpress.org/support/users/almahmudbd/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fmake-ordered-list-please%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

The topic ‘make ordered list please’ is closed to new replies.

 * ![](https://ps.w.org/list-all-posts-by-authors-nested-categories-and-titles/assets/
   icon-256x256.jpg?rev=1070306)
 * [List all posts by Authors, nested Categories and Titles](https://wordpress.org/plugins/list-all-posts-by-authors-nested-categories-and-titles/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/list-all-posts-by-authors-nested-categories-and-titles/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/list-all-posts-by-authors-nested-categories-and-titles/)
 * [Active Topics](https://wordpress.org/support/plugin/list-all-posts-by-authors-nested-categories-and-titles/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/list-all-posts-by-authors-nested-categories-and-titles/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/list-all-posts-by-authors-nested-categories-and-titles/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [almahmud](https://wordpress.org/support/users/almahmudbd/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/make-ordered-list-please/)
 * Status: not resolved