WordPress.org

Ready to get started?Download WordPress

Forums

PHP code to show only child list items (1 post)

  1. Jake Sterling
    Member
    Posted 1 year ago #

    I need the PHP to create a list of only child level pages. The situation is that have a menubar in the header section that lists all the site's Parent Pages. Then farther down (still in the header) I need another menubar based on a list of the children of the current Parent page. So, this list has to bring up the children of the current page if it is the parent, or, if it is one of the child pages, it has to bring up a list of the children of the parent page. (The reason for this has to do with the wishes of a graphic designer. I know that it would be easier just to use a single list. It will look good, though.)

    ******* EXAMPLE *******

    I need to divide this list,

    • WHO WE ARE
      • About Anisha
      • History
      • local Context
      • People
    • WHAT WE DO
      • Organic Farming
      • Native Seed Bank
      • Kitchen Gardens
      • Self Help
    • FACILITIES
    • DONATE
    • …so that the top list shows only the parent pages (That's the easy part)…

      WHO WE ARE * WHAT WE DO * FACILITIES * DONATE

      And then a second list that would show only the child level for a certain parent page. So, using WHAT WE DO for this example, both the parent page and its child pages would show this as the second list:

      Organic Farming * Native Seed Bank * Kitchen Gardens * Self Help

      I did figure out how to do this using a ridiculous CSS hack in which the parent level is supressed by making the font size zero. But I would like to do something a little less ugly.

      I imagine this problem has been addressed before, but I can't seem to find it by searching, or maybe I just don't understand what I am looking at. I am not that good at PHP. Thanks for any help.

Topic Closed

This topic has been closed to new replies.

About this Topic