[resolved] Excluding Subpages from Post-to-Page Mod (4 posts)

  1. dbz_gt_crazy
    Posted 2 years ago #

    Caroline, I used the simple code mod: <?php query_posts('post_type=page'); ?>

    in a child theme to make the circles link to pages. But now all subpages end up as circles on the homepage, too, of course. Is there a way to exclude subpages from the loop? I'd imagine it would be simple, but I don't know any programming.


  2. dbz_gt_crazy
    Posted 2 years ago #

    Nevermind! Got my answer!

    This array syntax worked:

    query_posts( array(
    'post_type' => 'page',
    'post_parent' => 0 ) );

    source: http://wordpress.stackexchange.com/questions/37507/how-to-hide-all-child-pages-with-post-query

  3. aneglia
    Posted 2 years ago #

    This is exactly the solution I need, but i get a syntax error when i put it in the code. I tried the link you provide as well, but i'm new to wordpress, and I'm not getting it.

    Could you tell me which file to modify (I assumed 'index.php') and where in the body of the code to place the array syntax.


  4. ShaiRoelud
    Posted 2 years ago #

    Try this:
    <?php query_posts('post_type=page&post_parent=0'); ?>

    in the index.php file in your child theme, in between:
    <?php endif; ?>

    <?php if ( have_posts() ) : ?>

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic