• Resolved John

    (@mav3000)


    Hi, I’ve read all about wp_list_pages but cannot get this to work. I’m fairly new to WordPress and am just learning the ropes.

    I have a blog with an ‘Events’ page. Within this I have three ‘Event’ sub-pages, with the view to add more as needed.

    I’d like to list the ‘Events’ on the blog homepage.

    How can I do this?

    Thanks for any help you may be able to offer.

    Richard

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Richard,

    Do you mean that you want to list all the sub-pages of the Events page on your blog’s “homepage” (by which I assume you mean the index page)?

    If your site is somewhere online, a link should also be handy.

    Thread Starter John

    (@mav3000)

    Hi Avanimisra, you are correct. I have the following page hierarchy:

    index.php
    events
    event1
    event2
    event3

    all of the event pages are created dynamically in wordPress. I need to list the individual events on the index.php page.

    I will then need to list the individual ‘events’ on the events page, but this could well be the same code I hope.

    I am making the site offline at the moment while I wait for a domain transfer to complete, so unfortunately cannot post a URL at this time.

    also, just to confirm I wish to list the event ‘children’ without the ‘events’ parent also being shown.

    Any ideas?

    Richard,

    This plugin comes tantalizingly close ?? But, it’ll display the sub-pages of only the current page, from what I gather.

    What happens if you try this:

    <?php
      $children = wp_list_pages('title_li=&child_of='.**PAGEID**.'&echo=0');
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    in your template file? Make sure you replace **PAGEID** with the ID for the events page.

    Could you test it and pingback?

    (And you could call me Avani!)

    Thread Starter John

    (@mav3000)

    Hi Avani,

    Thank for very much for such a quick reply. Your code works perfectly!

    I removed the
    unordered list tags to keep the event sub-page list in a single unordered list, which lists the sub-categories perfectly, excluding everything else.

    My final code looks like this within my sidebar:


    <div class="links"><!-- links -->

    • <h2>Event List 2</h2>
      <?php $children = wp_list_pages('title_li=&child_of=12&echo=0');
      if ($children) { ?>
      <?php echo $children; ?>
      <?php } ?>

    </div> <!-- added for tidiness -->

    Thanks again – I’ll recycle this snippet on my other pages.

    Richard,

    Awesome – and you’re most welcome, I’m glad it works ??
    (I should have noted that you wouldn’t need the ul tags…)

    You may want to mark this thread as “Resolved” if you opened this as a request for support.

    Cheers,
    Avani

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How To List Certain Sub-Categories’ is closed to new replies.