• Resolved ArielZusya

    (@arielzusya)


    I’m pulling content from two child pages into a parent page. I have them pulled in menu order. The code I’m using is:

    <?php
    	$pages = get_pages('child_of='.$post->ID.'&sort_column=menu_order&sort_order=asc&parent='.$post->ID);
    	$count = 0; foreach($pages as $page) {
    		$content = $page->post_content;
    		if(!$content) continue;
    			if($count >= 2) break;
    			$count++;
    ?>

    but I’d like to wrap that in an if statement that formats any child being pulled in with a menu order greater than 1 a particular way. I’m struggling with that conditional statement. Here’s what I tried (but which didn’t work because I’m making some rookie mistake *grrr*):

    <?php if ($post->ID.'&menu_order' > 1) { ?>

    what am I doing wrong? I’m sure it’s something simple. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • UNTESTED:

    <?php
    $pages = get_pages('child_of='.$post->ID.'&sort_column=menu_order&sort_order=asc&parent='.$post->ID);
    if( $pages ) {
    	$count = 0;
    	foreach($pages as $page) {
    		$content = $page->post_content;
    		if(!$content) continue;
    		$content = apply_filters('the_content', $content);
    		$count++;
    		if($count == 1) {
    			echo '<h2><a href="' .get_page_link($page->ID) .'">' .$page->post_title .'</a></h2>';
    		?>
    		<div class="my_entry_class">
    			<?php echo $content; ?>
    		</div>
    		<?php
    		} else {
    			echo '<h2><a href="' .get_page_link($page->ID) .'">' .$page->post_title .'</a></h2>';
    		?>
    		<div class="entry_class">
    			<?php echo $content; ?>
    		</div>
    		<?php
    		}
    	}
    }
    ?>

    HTH

    David

    Thread Starter ArielZusya

    (@arielzusya)

    Perfect! You rock! Thanks for the help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘if then trouble’ is closed to new replies.