Forums

If children, parent title, if not, No title! (3 posts)

  1. rickmesser
    Member
    Posted 1 month ago #

    So...
    New to php and wordpress, but LOVE it!
    I am listing sub navigation in the sidebar only for pages "parents" that have children. It works great, but I can't figure out how to add the title of the current parent above the list??
    Here's the code:

    <?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 } ?>

    Here it is in action:
    Page with children
    Page with no children
    I feel like if I had a better grip on the syntax of php I could easily get this. Being a beginner though, I find it VERY confusing??

    Anybody lend a quick hand?

  2. rickmesser
    Member
    Posted 1 month ago #

    Sorry! This is TOTALLY posted in the wrong place. I re-posted here under "Plugins and Hacks"

  3. rickmesser
    Member
    Posted 1 month ago #

Reply

You must log in to post.

About this Topic