• Hey all,

    I’m trying to display a navigation on my sidebar but I want it in a certain way that I’m not able to get through with.
    Right now I’m using this code:

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

    It works fine but there are some issues (I’ve tried the code below that one also from https://codex.www.ads-software.com/Template_Tags/wp_list_pages#List_subpages_even_if_on_a_subpage ) but no good.

    I’ve created a diagram of what exactly I’m looking for. If I was a little better at creating custom code then it would be smooth but unfortunately I can’t till now so all my hope lies on this community ??

    Here’s the deal:
    https://i42.tinypic.com/hx98n6.jpg

    Please help me ??
    Thanks in advance

Viewing 6 replies - 1 through 6 (of 6 total)
  • Did you notice this note?:

    This code will not work if placed after a widget block in the sidebar.

    Give us a link.

    Thread Starter beyonddesigning

    (@beyonddesigning)

    Hey,

    Thanks for the response.
    I don’t have any widget running on my sidebar right now.

    Here’s my source code:

    sidebar.php

    <div class="sidebar">
    
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : // begin primary sidebar widgets ?>
    
    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&amp;child_of=".$post->post_parent."&amp;echo=0");
      else
      $children = wp_list_pages("title_li=&amp;child_of=".$post->ID."&amp;echo=0");
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>
    
    <?php endif; // end primary sidebar widgets  ?>
    
    </div>

    The code doesn’t give any error, only the output is something that I don’t want and because I don’t know much php I’m not able to create a custom code for this ??

    can u give me a link? it works fine on my blog

    Thread Starter beyonddesigning

    (@beyonddesigning)

    Nah it works fine with my blog too but only the output is not what I want ??

    Unfortunately I’m working on my localhost so I don’t have a link to show.
    That is why I’ve given the link to the diagram I’ve made. Its exactly like the output I get.

    To sum it up:
    There are no errors, only the output style is different. I just want the navigation to display the child level 1 navigation no matter on what page.
    Maybe something to do with conditional tags, I wish I knew lol!

    Thread Starter beyonddesigning

    (@beyonddesigning)

    Sign ?? anyone?

    Thread Starter beyonddesigning

    (@beyonddesigning)

    Wow this is the first time it happened! No replies at all ??
    Guess everyone’s on holiday.

    I’m a sad man :/

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP list pages. Need little help’ is closed to new replies.