Jump to content

Wordpress - List child pages and parent page?


Recommended Posts

Wordpress - List child pages and parent page?

 

Hi all

 

This is the 3rd day on this now, it's driving me mad.

 

I'm trying to create a Wordpress photo gallery theme, I want a gallery with sub sections.

 

http://www.ttmt.org.uk/wordpress/

 

In the demo I have 'Transport' with the sub sections Boats and Cars.

 

I have 3 pages - Transport, Boats and Cars. Boast and Cars are child pages of Transport.

 

Each page has a NextGen Gallery as it's content.

 

When you click Transport the gallery loads and the child pages are shown in a list above.

 

The child pages are added with this:

 

<?php

    if($post->post_parent){
    	$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); 
    	$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) { 
    	echo '<ul class="submenu">';
    		echo $children;
    	echo '</ul>';
    }
    ?>

 

How can I add the actual page 'Transport' to this list?

 

If you click on Boats or Cars 'Transport' is added to the list, this because it is then a parent.

 

How can I have a sub menu of Transport, Boats, Cars when 'Transport' is clicked?

 

ANY help with this would be greatly appreciated.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.