WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working with a company's About page. I created a custom post type for "Employees", and am using the Advanced Custom Fields plugin to create simple meta boxes for name, title, image, and bio.

The first employee listed is the owner, and i'd like to style his bio differently from the rest, but my php skills aren't quite up to the task.

Here is the code i'm working with so far, I just need to understand how to create a variable for the first post in the array and style it differently.

    $args = array('post_type' => 'employee');
    $employee= new WP_Query( $args );
    if( $employee->have_posts() ) {
    while( $employee->have_posts() ) {

    <div <?php post_class('portrait'); ?>>
        <img src="<?php the_field('employee_photo'); ?>" alt="" />
        <h3><?php the_title() ?></h3>
        <span><?php the_field('employee_title'); ?></span>
        <p><?php the_field('employee_bio'); ?></p>

        else { ?>
            <div class="portrait">
            <img src="<?php the_field('employee_photo'); ?>" alt="" />
            <h3><?php the_title() ?></h3>
            <span><?php the_field('employee_title'); ?></span>
            <p><?php the_field('employee_bio'); ?></p>
    <?php } ?>
share|improve this question

You can check current_post in the loop. Just remember it's zero-indexed, so first is 0, second is 1, etc.:

if( 0 == $employee->current_post ):
    // this is the first post
    // this is > first post
share|improve this answer
I understand that concept, but I'm not sure where to place that code without erring out my server, given the code block I pasted above. – joshlawler7 Jan 11 '13 at 16:35
I ended up figuring out this solution, with some extra help from this thread: link – joshlawler7 Jan 11 '13 at 17:02
@joshlawler7, would be nice if you added your own Answer with the solution, this meta item may help: How does accepting an answer work?. – brasofilo Jan 12 '13 at 15:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.