Title: Section Subnav on Single/Posts &#8216;Pages&#8217;
Last modified: August 19, 2016

---

# Section Subnav on Single/Posts ‘Pages’

 *  [gamehen9](https://wordpress.org/support/users/gamehen9/)
 * (@gamehen9)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/section-subnav-on-singleposts-pages/)
 * I’ve got a sub navigation area on [my site](http://www.morevikings.com) with 
   code that uses conditional statements to display a section title for the level
   1 category/page and follows it with a list of all the level 1’s subcategories/
   subpages.
 * This title and list change when the section changes. So, if you’re in Book Reviews
   the subnav has a ‘Book Reviews’ title and subcategories list and if you’re in
   Rants the subnav has a ‘Rants’ title and subcategories list. It works the same
   on my Pages.
 * HOWEVER, my big problem is that I can not get this to work on the singles/posts.
   I CAN get WordPress to list a single section’s subcategories on ALL the post ‘
   pages’. I just can’t get any conditional statements to work so that a book review
   shows JUST the Book Reviews subnav and a rant has just the Rants subnav.
 * I’m frustrated as all-get-out.
 * My site, for reference, is [http://www.morevikings.com](http://www.morevikings.com)
 * The code I can get to work is:
 *     ```
       echo "<ul>";
       wp_list_categories('orderby=name&hide_empty=0&child_of=1&title_li=<h2>Book Reviews</h2>');
       echo "</ul>";
       ```
   
 * I have this difficulty whether I try conditional statements for this in sidebar.
   php or in single.php
 * I’ve tried using is_single, in_category, is_category, etc.
 * This is a theme I created and am developing.
 * The following is the subnav code that is working on the Category and Page ‘pages’.
   It’s clunky but all I can get to work:
 *     ```
       <?php
       //
       if (is_home()) {
               // show a list of all top-level categories on home page
                    echo "<ul>";
                    wp_list_pages('orderby=name&child_of=111&title_li=<h2>More About moreVikings</h2>');
       			 echo "</ul>";
       // subnav for categories sections
       } elseif (is_category()) {
               // test if it's in the Book Review section and display a title and subcategories list
               if (is_category(array(1,17,18,19,20,21,22,23,24,25,30,31,32,33,34,35,36))) {
                    echo "<ul>";
                    wp_list_categories('orderby=name&hide_empty=0&child_of=1&title_li=<h2>Book Reviews</h2>');
                    echo "</ul>";
               // test if it's in the Rects and Rants section and display a title and subcategories list
                } elseif (is_category(array(41,42,43))) {
                     echo "<ul>";
                    wp_list_categories('orderby=name&hide_empty=0&child_of=41&title_li=<h2>Book Recs and Rants</h2>');
                    echo "</ul>";
               } else {
                     // catch-all for other categories
                     echo "&nbsp;";
               }
       // subnav for pages
       } elseif (is_page()) {
               // test if it's in the About section and display a title and subcategories list
               if (is_page(array(2,4,5,6,7,111))) {
                    echo "<ul>";
                    wp_list_pages('orderby=name&child_of=2&title_li=<h2>About moreVikings</h2>');
       			 echo "</ul>";
               } else {
                     // catch-all for other pages
                     echo "&nbsp;";
               }
       } else {
               // catch-all for everything else (archives, searches, 404s, etc)
               echo "&nbsp;";
       }
       ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/section-subnav-on-singleposts-pages/#post-1397820)
 * Have you looked at using [in_category()](http://codex.wordpress.org/Template_Tags/in_category)?
 *  Thread Starter [gamehen9](https://wordpress.org/support/users/gamehen9/)
 * (@gamehen9)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/section-subnav-on-singleposts-pages/#post-1398067)
 * Yes.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Section Subnav on Single/Posts ‘Pages’’ is closed to new replies.

## Tags

 * [category list](https://wordpress.org/support/topic-tag/category-list/)
 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [single](https://wordpress.org/support/topic-tag/single/)
 * [Subnav](https://wordpress.org/support/topic-tag/subnav/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [gamehen9](https://wordpress.org/support/users/gamehen9/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/section-subnav-on-singleposts-pages/#post-1398067)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
