Advertisement
Guest User

Untitled

a guest
Aug 17th, 2011
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <div id="sidebar">
  2. <div id="category-list">
  3. <ul id="topnav">
  4. <?php
  5.  
  6. global $post;
  7. $postcategories = get_the_category();
  8. $postcategory = $postcategories[0]->cat_ID;
  9. $pid = $post->ID;
  10. $post_categories = wp_get_post_categories( $post->ID );
  11. $cats = array();
  12. foreach($post_categories as $c){
  13. $cat = get_category( $c );
  14. $cats[] = $cat->ID;
  15. }
  16. $active_cat_count = true;
  17. $cat_count = 0;
  18.  
  19.  
  20. $kategorien = get_categories(array(
  21. 'child_of' => 0,
  22. 'exclude_tree' => 15,
  23. 'exclude' => 16,
  24. 'orderby' => 'slug',
  25. 'order' => 'ASC'));
  26. foreach($kategorien as $kategorie) {
  27. if (isset($active_cat_count) && $active_cat_count){
  28. if (in_array($kategorie->ID,$cats)){
  29. $active_cat_count = false;
  30. }else{
  31. $cat_count = $cat_count + 1;
  32. }
  33. }
  34. $cat = $kategorie->cat_ID;
  35. echo '<li class="cid-'. $cat .'"><a href="#" class="category-title">'; echo ($kategorie->name); echo '</a>';
  36. echo '<ul>';
  37. $posts = get_posts('category='. $cat .'&posts_per_page=-1');
  38. foreach($posts as $post) { ?>
  39. <li>
  40. <a <?php if ($post->ID == $pid) echo 'class="current"'; ?> href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  41. <li>
  42. <?php }
  43. echo '</ul>';
  44. echo '</li>';
  45. }
  46. ?>
  47. </ul>
  48. </div>
  49.  
  50. <script>
  51. $("#topnav").accordion({
  52. closedSign: '+',
  53. openedSign: '-',
  54. active: '.cid-<?php echo $postcategory; ?>'
  55. });
  56. </script>
  57.  
  58.  
  59. <span>Post-Kategorie-ID: <?php echo $postcategory; ?></span>
  60.  
  61. <?php
  62. if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) :
  63. endif; ?>
  64. </div><!-- #sidebar -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement