WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Show all posts as menu dropdowns in category sidebar (4 posts)

  1. ernaparalla
    Member
    Posted 1 year ago #

    Hi all,
    This is proving more difficult that I had thought. Currently only the categories in my portfolio sidebar are shown but I would like click on each category menu item and have all posts within it show as a submenu, with only one submenu allowed open at a time. Additionally, I would like this same sidebar to be displayed as you navigate from portfolio landing page to category landing page to a single portfolio post.

    Category A
    Category B
    Post 1
    Post 2
    Post 3

    Category C

    Existing code for sidebar in Portfolio Page Template (template-portfolio.php):

    [ Moderator note: Please wrap code in backticks or use the code button. ]

    <!--BEGIN .sidebar -->
                	<div class="sidebar">
                        <?php the_content(); ?>
                         <ul id="filter">
                          <?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'skill-type', 'walker' => new Portfolio_Walker())); ?>		
    
                    <!--END .sidebar -->

    Existing code in functions.php:

    class Portfolio_Walker extends Walker_Category {
       function start_el(&$output, $category, $depth, $args) {
          extract($args);
          $cat_name = esc_attr( $category->name);
          $cat_name = apply_filters( 'list_cats', $cat_name, $category );
    	  $link = '<a href="#">term_id.'" ';
          if ( $use_desc_for_title == 0 || empty($category->description) )
             $link .= 'title="' . sprintf(__( 'View all items filed under %s' ), $cat_name) . '"';
          else
             $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
          $link .= '>';
          // $link .= $cat_name . '</a>';
          $link .= $cat_name;
          if(!empty($category->description)) {
             $link .= ' <span>'.$category->description.'</span>';
          }
          $link .= '';
          if ( (! empty($feed_image)) || (! empty($feed)) ) {
             $link .= ' ';
             if ( empty($feed_image) )
                $link .= '(';
             $link .= '<a>term_id, $feed_type) . '"';
             if ( empty($feed) )
                $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
             else {
                $title = ' title="' . $feed . '"';
                $alt = ' alt="' . $feed . '"';
                $name = $feed;
                $link .= $title;
             }
             $link .= '>';
             if ( empty($feed_image) )
                $link .= $name;
             else
                $link .= "<img src='$feed_image'$alt$title" . ' />';
             $link .= '</a>';
             if ( empty($feed_image) )
                $link .= ')';
          }
          if ( isset($show_count) && $show_count )
             $link .= ' (' . intval($category->count) . ')';
          if ( isset($show_date) && $show_date ) {
             $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
          }
          if ( isset($current_category) && $current_category )
             $_current_category = get_category( $current_category );
          if ( 'list' == $args['style'] ) {
              $output .= '<li class="segment-'.rand(2, 99).'"';
              $class = 'cat-item cat-item-'.$category->term_id;
              if ( isset($current_category) && $current_category && ($category->term_id == $current_category) )
                 $class .=  ' current-cat';
              elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) )
                 $class .=  ' current-cat-parent';
              $output .=  '';
              $output .= ">$link\n";
           } else {
              $output .= "\t$link\n";
           }
       }
    }

    Thanks!

  2. ernaparalla
    Member
    Posted 1 year ago #

    Can this post please be removed, I've rephrased to exclude 'dropdown menus'. Thanks.

  3. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    It is not the general policy to edit or delete forum posts. When a post is made and people contribute answers to an issue, that then becomes part of the community resource for others to benefit from. Deleting posts removes this added value. In extreme circumstances, the moderation team might be persuaded to remove sensitive information but. generally, your best course of action is not to publish anything that you wouldn't want to be public. I'm sorry but this is not an extreme case.

    http://codex.wordpress.org/Forum_Welcome#Deleting_.2F_Editing_Posts

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    as you have choosen to continue this under an new heading, I am closing this topic
    (although generally it is not a good enough reason not to continue with this topic only because of a minor edit of the topic title).

    continued at http://wordpress.org/support/topic/display-posts-under-categories-in-sidebar-1?replies=1

Topic Closed

This topic has been closed to new replies.

About this Topic