ThemeShaper Forums » Thematic

[closed]

Help adding category Sub-menus above content on category and child pages

(4 posts)
  • Started 2 years ago by candregg
  • Latest reply from candregg
  • This topic is not resolved
  1. Greetings--

    I am trying to add a dynamic sub-menu above the content. The menu would only show sub categories within a category when a user was in that category.

    See the code I'm trying below, derived from this forum and the WP codex:

    //   Add category Sub-menus above content on category and child pages
    
    function custom_childtheme_catmenus(){
    	if( is_category() ) :
    $this_cat_id = get_query_var('cat');?>
    
    <div id="category-sub-menu">
    <ul class="cat-menu">
    <?php wp_list_categories('child_of=' . $this_cat_id); ?>
    </ul>
    
    </div><!-- end custom child category menu -->
    
    <?php }}
    
    add_action('thematic_abovecontent','custom_childtheme_catmenus');

    I keep getting an error flag at the line

    <?php }}

    I'm sure it's something stupid, like leaving out a requisite } or ; character. My syntax is not that good.

    Any help would be appreciated.

    Posted 2 years ago #
  2. you are mixing {} and if: endif; syntax.

    if you use { to open an if statement, close it with a }

    if you use if: to open and if statement, close it with endif;

    so in the case above, change

    if( is_category() ) :

    to

    if( is_category() ) {
    Posted 2 years ago #
  3. That worked great! Thank you, Helga.

    This is the resulting code on the website:

    <div id="category-sub-menu">
    <ul class="cat-menu">
    <li class="categories">Categories<ul>	<li class="cat-item cat-item-5652"><a href="http://seacliffmm.com/prod/indigest/admin/?cat=5652" title="View all posts filed under InDialogue">InDialogue</a>
    </li>
    	<li class="cat-item cat-item-5651"><a href="http://seacliffmm.com/prod/indigest/admin/?cat=5651" title="View all posts filed under Music">Music</a>
    </li>
    	<li class="cat-item cat-item-5650"><a href="http://seacliffmm.com/prod/indigest/admin/?cat=5650" title="View all posts filed under News">News</a>
    </li>
    	<li class="cat-item cat-item-5653"><a href="http://seacliffmm.com/prod/indigest/admin/?cat=5653" title="View all posts filed under Reviews">Reviews</a>
    </li>
    </ul></li></ul>
    
    </div><!-- end custom child category menu -->

    How do I modify this code to exclude the first level UL

    <li class="categories">Categories<ul> ...
    
    ...</li></ul>

    and restrict the output to show ONLY the children of the current category. Is there some kind of exclude that I can use? Or can I css "display none" on that top element without making the lower elements disappear as well?

    You can see the site developing at http://seacliffmm.com/prod/indigest/admin/?cat=5648. Be advised that I'm having server issues, so some parts might look messed up (especially the main nav.) Tech support is working on it.

    Thanks!

    Posted 2 years ago #
  4. I also have to figure out the code to make it NOT display at all if no sub categories exist.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.