• Resolved Libin

    (@libinvbabu)


    Hi,

    I am creating a website using wordpress 3.2.1 with twenty ten theme.

    I have a main navigation and all parents have children.
    Eg:
    Page A: Child 1
    Child 2
    Page B
    Child 3
    Child 4

    I need to include a horizontal submenu on sidebar. But my problem is, If currently we are on page A, all the child items of page A only to be displayed on sidebar.
    If we are on Page A, sidebar should looks like:
    Page A
    Child 1
    Child 2

    Like this, when we go to Page B, the child of page B only to be displayed.

    Please help me.

    Thanks in advance.

    Regards,
    Libin

Viewing 5 replies - 1 through 5 (of 5 total)
  • Don’t edit the Twenty Ten theme. Instead create a child theme for your customisations. Once your child theme is active, see this Codex section.

    Thread Starter Libin

    (@libinvbabu)

    Hey Esmi,

    Thank you so much for your help.
    Now I am working on a child theme and the following code fix my problem.

    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    But I need to display the current parent as the title for these sub menus. ie, I need the current parent page’s name as heading. Please help me.
    Thank you so much for helping me.

    Thread Starter Libin

    (@libinvbabu)

    Hey,

    I had figure out my problem by using the code below. This code will show the parent’s name also as heading.!

    <?php
      if($post->post_parent) {
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      $titlenamer = get_the_title($post->post_parent);
      }
    
      else {
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      $titlenamer = get_the_title($post->ID);
      }
      if ($children) { ?>
    
      <h2> <?php echo $titlenamer; ?> </h2>
      <ul>
      <?php echo $children; ?>
      </ul>
    
    <?php } ?>

    Once again thank you esmi for helping me.

    Assalam-u-alaikum

    i have designed menu and submenus ,but submenues shows underneath the slider images when mouse is hover on the main menu.
    Anothor problem is that when we want to move from main menu item to its submenu ,then to leave the main menu item submenus of that item is automatically hides.
    please help me…..

    Thread Starter Libin

    (@libinvbabu)

    Provide the link to your website to check it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display current parent and its sub-menu only on sidebar’ is closed to new replies.