Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="sidebar">
- <div id="category-list">
- <ul id="topnav">
- <?php
- global $post;
- $postcategories = get_the_category();
- $postcategory = $postcategories[0]->cat_ID;
- $pid = $post->ID;
- $post_categories = wp_get_post_categories( $post->ID );
- $cats = array();
- foreach($post_categories as $c){
- $cat = get_category( $c );
- $cats[] = $cat->ID;
- }
- $active_cat_count = true;
- $cat_count = 0;
- $kategorien = get_categories(array(
- 'child_of' => 0,
- 'exclude_tree' => 15,
- 'exclude' => 16,
- 'orderby' => 'slug',
- 'order' => 'ASC'));
- foreach($kategorien as $kategorie) {
- if (isset($active_cat_count) && $active_cat_count){
- if (in_array($kategorie->ID,$cats)){
- $active_cat_count = false;
- }else{
- $cat_count = $cat_count + 1;
- }
- }
- $cat = $kategorie->cat_ID;
- echo '<li class="cid-'. $cat .'"><a href="#" class="category-title">'; echo ($kategorie->name); echo '</a>';
- echo '<ul>';
- $posts = get_posts('category='. $cat .'&posts_per_page=-1');
- foreach($posts as $post) { ?>
- <li>
- <a <?php if ($post->ID == $pid) echo 'class="current"'; ?> href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
- <li>
- <?php }
- echo '</ul>';
- echo '</li>';
- }
- ?>
- </ul>
- </div>
- <script>
- $("#topnav").accordion({
- closedSign: '+',
- openedSign: '-',
- active: '.cid-<?php echo $postcategory; ?>'
- });
- </script>
- <span>Post-Kategorie-ID: <?php echo $postcategory; ?></span>
- <?php
- if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) :
- endif; ?>
- </div><!-- #sidebar -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement