• I am building a one page website with the parent PAGE content at the top and the child PAGE contents displaying below (that part works fine) – but I need to style each child page section differently… How do I grab the child page slug and use it as a selector in each section?

    Here’s what I have:

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    	<div class="section" id="hero">
    		<?php the_content(); ?>
    		<?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
    		<?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>
    	</div>
    
    	<?php
    		$pages = get_pages('child_of='.$post->ID.'&sort_column=menu_order');
    		$count = 0;
    		foreach($pages as $page)
    		{
    		$content = $page->post_content;
    		?>
    		<div class="section" id="<strong>HERE IS WHERE I NEED THE CHILD PAGE SLUG</strong>">
    			<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
    			<p><?php echo $content ?></p>
    		</div>
    		<?php
    		}
    	?>
    
    <?php endwhile; ?>

    Thanks!

  • The topic ‘Use child page slug as a selector’ is closed to new replies.