• edwardtownend

    (@edwardtownend)


    I’m trying to allow users to feature page/s on the homepage of a site, so I have created the custom tag homepage-featured, of which the value will specify the order it is presented on the homepage. Not foolproof, I know, as users could set the same order, but never mind. Here’s the code I’m using on the homepage to pull through the featured page number 1:

    <?php //get featured-halfwidth (custom:1)
    global $post;
    $args = array( 'meta_key' => 'homepage-featured', 'meta_value' => '1' );
    $myposts = get_pages( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    
    <div class="col300 featured-box">
    
    	<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    
    	<p><?php echo get_post_meta( $post->ID, 'homepage-text', 1 ); ?></p>
    
    	<a href="<?php the_permalink(); ?>" class="learn-more">Learn more ›</a>
    
    </div>
    <?php endforeach;?>

    Now this works fine while the page I’m featuring has no parent, but as soon as I assign a parent to the page it no longer shows on the homepage. I thought by default get_pages pulls through all pages regardless of if it is a child or not? Any ideas as to how I can resolve this?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Get_pages problem with child pages’ is closed to new replies.