Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates From Bootstrap to WordPress Template: Part 2

One of the review questions is giving me grief !!

to get the current post count in the loop is :

the_query->current_post + 1;

is it not ?

2 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

The challenge question may be a little ambiguous.

I believe the question is meant to be requesting the current post array index value, and not the human readable equivalent of the current count of the Loop. Simply, $the_query->current_post.

Thanks Sean, after 15 attempts of putting in the "Right" answer, I appreciate your guidance. Thankyou

Hi vaughnkennett,

i think "$the_query->current_post" (with dollar-sign, without +1) should actually work but i've heard people having problems with this where using "$wp_query->current_post" instead worked for them.

another solution could be the following:

<?
$loop_counter = 0;
while( $query->have_posts() ) {
    //post content goes here
    $loop_counter++;
}
?>

Appreciate your help here, and your real world alternative is a great option. thankyou