So for now, every iteration looks the same and it’s been a while since I dealt with php so could you help me?
<?php
$pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
$count = 0;
foreach($pages as $page)
{
$content = $page->post_content;
if(!$content)
continue;
if($count >= 2)
break;
$count++;
$content = apply_filters('the_content', $content);
?>
<div id="<?php echo $page->post_title ?>">
<h2><?php echo $page->post_title ?></h2>
<?php echo $content ?>
</div>
<?php
}
?>
I’ve look there and there and found that I coud Use something like this
<?php foreach ($pages as $page) : start_wp(); ?>
<?php if ($i == 1) : ?>
//first iteration
<?php else : ?>
//the rest
you should use
$wp_query
to retrieve pages and posts because it’s the most efficient way and you can differentiate the loop with$current_post
parameter which returns the index of the loop.It works like this
Have a look at the if structure. You can use the post index
current_post
like that.You can customize the query the way you like.
Reference: WP_Query Codex
I think this is more of a PHP question than a wordpress question. If I have understood clearly you want the first result of the loop to be styled differently from the others. This is how I would do it.