Hi,
I would like to apply different style class to category navigation.So, I am using a custom function to display all categories.My script as follows
function your_list_categories($args){
$defaults = array(
'show_option_all' => '', 'show_option_none' => __('No categories'),
'orderby' => 'name', 'order' => 'ASC',
'show_last_update' => 0, 'style' => 'list',
'show_count' => 0, 'hide_empty' => 1,
'use_desc_for_title' => 1, 'child_of' => 0,
'feed' => '', 'feed_type' => '',
'feed_image' => '', 'exclude' => '',
'exclude_tree' => '', 'current_category' => 0,
'hierarchical' => true,
'echo' => 1, 'depth' => 0,
'taxonomy' => 'category'
);
$r = wp_parse_args( $args, $defaults );
$categories = get_categories( $r );
$output = '';
foreach ($categories as $category) {
if($category->name == "BEGINNER'S LESSONS"){
$output .= '<li><a class="beginner" href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></li>';
} else {
$output .= '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></li>';
}
}
echo $output;
}
add_filter('wp_list_categories', 'your_list_categories');
Invoking this function from my header.php
as follows
<?php
$args=array(
'orderby' => 'name',
'depth' => 1,
'hierarchical' => 1,
'order' => 'DESC'
);
your_list_categories($args);
?>
Here how can I hide all subcategories.Please help me.