Wordpress - Listing subpages

Discussion in 'Programming' started by emforce, Dec 27, 2009.

  1. #1
    Hi guys I was wondering how I would deal with this problem.

    I am trying to improve the structure of my site, so that I can accommodate things like mission walkthroughs for my games. I have created a separate sub category for each game and a sub page for each game. I have the code to list the category posts on my page but how would I change it so that I can list my sub categories? for instance - Games/Assassin's Creed 2?

    Here is the code I used for listing categories.

    <?php $query = new WP_Query('category_name=games&showposts=100&orderby=title&order=ASC');
    while ($query->have_posts()) : $query->the_post(); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <br/>
    <?php endwhile; ?>

    How would I do it for sub categories?

    for instance if the Main page was PS3 games, how would I list every sub page of that page?

    Thanks!
     
    Last edited: Dec 27, 2009
    emforce, Dec 27, 2009 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    I think this little example can help you

    
    <?php
    $subcategories = get_categories('child_of='.get_cat_ID('Games'));
    ?>
    
    Code (markup):
     
    s_ruben, Dec 28, 2009 IP