I am trying to reduce the number of files in my theme, and hopefully prevent users from having to choose between page templates to make sure the pages display correctly. Therefore this is what i want to do in my sidebar.php but am struggling:
I want some code that will do the following:
Check to see if the page has child pages.
If so display them as an unordered list.
If the page is a child page and doesn't have any child pages of its own, then display other child pages of the parent page in an unordered list.
If it doesn't have child pages then list the categories (top level) and archives (monthly).
That is basically the 'English' of what I would like to do and I was wondering whether someone could give me the 'php' code.
I have looked in the codex at conditional tags and some plugins but i have not managed to crack it after 3 hours of struggle.
Thanks in advance.