WordPress.org

Ready to get started?Download WordPress

Forums

Get Pages by Parent (4 posts)

  1. scanscan
    Member
    Posted 4 years ago #

    I'm trying to get pages where the parent of those pages is 157. I thought this would do the trick:

    <?php $my_loop = new WP_Query('post_parent=157'); ?>
    <?php while ($my_loop->have_posts()) : $my_loop->the_post(); ?>

    But it's not working. ot sure where else to turn. Thoughts? Thanks!

  2. scanscan
    Member
    Posted 4 years ago #

    Anyone have an idea why this isn't working?

  3. JoE
    Member
    Posted 4 years ago #

    I'm looking at some stuff along the same lines. How do you even relate a post to a parent?

  4. mjoanisse
    Member
    Posted 4 years ago #

    Hi there.. not sure if this is what you're looking for.. but if so, here is what i use:

    `<?php if ($post->post_parent == '2') {
    //code to run
    ?>`

    Good luck - cheers

Topic Closed

This topic has been closed to new replies.

About this Topic