Support » Themes and Templates » Get current category slug id for custom menu code

  • Resolved Pioneer Web Design


    Using Twenty Eleven Child Theme here

    I have added to header-arlene.php this:

    <nav id="access" role="navigation">
    <?php $args = array(
    	'type'                     => 'post',
    	'child_of'                 => '',
    	'parent'                   => '970',
    	'orderby'                  => 'name',
    	'order'                    => 'ASC',
    	'hide_empty'               => 1,
    	'hierarchical'             => 1,
    	'exclude'                  => '',
    	'include'                  => '',
    	'number'                   => '',
    	'taxonomy'                 => 'category',
    	'pad_counts'               => true );
    						$categories = get_categories($args);
    				foreach($categories as $category)
    				<ul><li><a href="<?php echo get_category_link( $category->term_id )?>" title="View posts in  <?php echo $category->name?>">
    					<?php echo $category->name?>
    			 <?php }

    I am calling for header-arlene.php in category-arlene.php (to test)

    So, the basics of what I am trying to achieve are ok.

    But, I do not want to have to create a ton of category and header templates.

    The site is a family tree site with categories and child-categories set just as you would expect.

    What I cannot for the life of me see after researching this now several times, is how to pass the category slug id to
    'parent' => 970,
    I guess I am unclear how to programmatically get the id of the current category slug and use that in place of a specific id (so I can then move all of this to header.php)

    (970 is cat id for arlene).

    The second menu is correct, it shows only the direct children of cat id 970. (see the drop down cat list).

    I must be missing something elementary but am unsure what!

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get current category slug id for custom menu code’ is closed to new replies.