0

I'm setting up an events page in a wordpress site I'm building.

Let's take a look at the page menu hierarchy:

First of all there is a Events landing page. It will display four regions where events are held. Inside the region are the events.

Menu example

This page is working as intended. The problem arrises when you click through to these pages and what is now shown.

When you click through to a region, I want a list of the events in that specific region to be shown. For example if you are on the page of region 2, I want all the events in region 2 listed.

I've made sure I've set this up correctly in the backend, with parent pages and such.

I'm using an example taken from the codex of wp_list_pages and I have created a new events template and created a new sidebar for the events template. I have added this within the sidebar of the events template (sorry a bit of a mouthful!):

http://codex.wordpress.org/Function_Reference/wp_list_pages

<?php
if($post->post_parent)
  $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
else
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
 class="icon-something"></i>');
if ($children) { ?>
<ul class="submenu-children">
  <?php echo $children; ?>
</ul>
<?php } ?>

This code is currently showing a list of pages on the same level as the page. So if I'm on Region 1, it shows all the regions and nothing else. I want to be able to see the Events if I'm on a Region. I'm thinking this may be the wrong chunk of code I'm looking for and perhaps below is more what I need to go with? (child of).

<ul>
<?php
wp_list_pages('title_li=&child_of='.$post->ID.'&show_date=modified
&date_format=$date_format'); ?>
</ul>

If anyone has any better ways or creating this kind of menu hierarchy I would love to hear how you would approach this. Thanks people.

1 Answer 1

0

If your "Events landing page" is a proper WordPress "Page", which I assume it is, then I think that all you need is:

$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
  1. On the landing page, you should get the four regions
  2. On a regions page you should get the regions children
  3. On the individual child pages you'd get nothing

I am not sure if #3 is what you want but #1 and #2 are correct, if I understand the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.