Support » Theme: Spun » Excluding Subpages from Post-to-Page Mod

  • Resolved dbz_gt_crazy

    (@dbz_gt_crazy)


    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.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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

    aneglia

    (@aneglia)

    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.

    Thanks!

    ShaiRoelud

    (@shairoelud)

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

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

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excluding Subpages from Post-to-Page Mod’ is closed to new replies.