WordPress.org

Ready to get started?Download WordPress

Forums

WP list pages. Need little help (7 posts)

  1. beyonddesigning
    Member
    Posted 5 years ago #

    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 http://codex.wordpress.org/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:
    http://i42.tinypic.com/hx98n6.jpg

    Please help me :)
    Thanks in advance

  2. Oren Yomtov
    Member
    Posted 5 years ago #

    Did you notice this note?:

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

    Give us a link.

  3. beyonddesigning
    Member
    Posted 5 years ago #

    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 :(

  4. Oren Yomtov
    Member
    Posted 5 years ago #

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

  5. beyonddesigning
    Member
    Posted 5 years ago #

    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!

  6. beyonddesigning
    Member
    Posted 5 years ago #

    Sign :( anyone?

  7. beyonddesigning
    Member
    Posted 5 years ago #

    Wow this is the first time it happened! No replies at all :(
    Guess everyone's on holiday.

    I'm a sad man :/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.