Title: Tabbed Categories and Posts
Last modified: August 20, 2016

---

# Tabbed Categories and Posts

 *  Resolved [dean-dolan](https://wordpress.org/support/users/dean-dolan/)
 * (@dean-dolan)
 * [14 years ago](https://wordpress.org/support/topic/tabbed-categories-and-posts/)
 * I’m trying to create a tabbed area with a list of categories which can be clicked
   to show the posts in each of them.
 * I’ve tried everything I can find and the latest attempt is this:
 *     ```
       <div id="tabs">
          <ul class="cat-list">
             <?php
             $cat_args = array(
                 'orderby' => 'name',
                 'order' => 'ASC',
                 'child_of' => 0
             );
   
             $categories = get_categories($cat_args);
   
             foreach ($categories as $category) {
                echo '<li> <a href="#' . ( $category->cat_ID ) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . '>' . $category->name . '</a></li>';
             }
             echo '</ul> ';
             foreach ($categories as $category) {
   
                echo '<div id="' . ( $category->cat_ID ) . '"><ul class="post-list">';
   
                $post_args = array(
                    'numberposts' => 20,
                    'category' => $category->term_id
                );
                echo '<pre>' . print_r($category, 1);
                $posts = get_posts($post_args);
   
                foreach ($posts as $post) {
   
                   echo '<li><a href="'.the_permalink().'">'.the_title().'</a></li>';
                }
                echo '</ul></div>';
             }
             ?>
       </div>
       ```
   
 * The categories must be listed in a
    -  and closed with the posts for each category being listed in a <div> with 
      the id of the category after
 * Any ideas?

The topic ‘Tabbed Categories and Posts’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [list](https://wordpress.org/support/topic-tag/list/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [dean-dolan](https://wordpress.org/support/users/dean-dolan/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/tabbed-categories-and-posts/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
