Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How do I create child pages which WP recognises (so I can use the $wpdb->get_results() function in them), and which I can display from my main/home page.

Would I then use normal a href="some url" ?? or is there a better and specific WP construct to use. Could that be a shortcode ?

TIA

share|improve this question
you can retrieve child pages from any page.... but child of who? your question is really hard to understand, which is ur scenario? – andrewkthx Feb 15 '12 at 8:14
2  
It's difficult to tell what is being asked here. This question is incomprehensible and cannot be reasonably answered in its current form. – Brady Feb 15 '12 at 15:24

closed as not a real question by Brady, Chip Bennett, toscho Apr 7 '12 at 21:09

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

Pages are by default children of the main page (or the root).

There are several ways to list them:

  1. Edit the front-page.php of your theme and use wp_list_pages(). To show just the first level of the pages use:

    wp_list_pages( array ( 'depth' => 1 );

    Pro: Easy to implement. Contra: not very flexible.

  2. Add a widget to your front-page.php and use the page widget. You need the following code in your functions.php:

.

function wpse_42387_sidebar_setup()
{
    register_sidebar(
        array (
            'name'          => 'Front Page'
        ,   'id'            => 'front-page-widget'
        ,   'before_widget' => '<div id="%1$s" class="widget %2$s">'
        ,   'after_widget'  => '</div>'
        ,   'before_title'  => '<h2>'
        ,   'after_title'   => '</h2>',
        )
    );
}
add_action( 'widgets_init', 'wpse_42387_sidebar_setup' );

In your front-page.php add:

<?php dynamic_sidebar( 'Front Page' ); ?>

Now you can add a widget from wp-admin/widgets.php to the field, even a custom menu.

 3. You use the shortcode from my short code plugin and add [subpages] to the page you’ve chosen as front page. The arguments are like wp_list_pages().

In all cases you don’t need to query the data base with a custom function.

share|improve this answer

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