Title: Getting first only post through wp post loop
Last modified: April 5, 2021

---

# Getting first only post through wp post loop

 *  [Rubel](https://wordpress.org/support/users/bluemoon86/)
 * (@bluemoon86)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/getting-first-only-post-through-wp-post-loop/)
 * [Code link](https://www.ideone.com/tE293h)
    Please see my code, only 14 lines.
   Currently my posts are now showing into 3 grids. But, i want the first post will
   be shown in full grid / full width. So, i want to give it a class. And, i wrote
   the below loop. But, this loop is printing all the posts, but it shouldn’t . 
   It should show only one post. What is wrong with my if checking and loop?
 * Kind Thanks.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fgetting-first-only-post-through-wp-post-loop%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/getting-first-only-post-through-wp-post-loop/#post-14279269)
 * Surely this isn’t the whole code, and you don’t want to actually output the $
   firstPost variable.
    I am thinking that your `else` clause does not have braces,
   so it could be hard to read what is happening. Instead of jumping in and out 
   of PHP, stay in PHP as long as the next thing you are doing is PHP. Only switch
   to HTML or PHP when you need to. That makes it easier to read.
 *  Thread Starter [Rubel](https://wordpress.org/support/users/bluemoon86/)
 * (@bluemoon86)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/getting-first-only-post-through-wp-post-loop/#post-14279315)
 * Thanks for your reply.
    Currently, my page is showing all the blog posts into
   3 grids. But, i want, first post to show in full width and other posts will be
   shown in 3 grids. Thats why, I want to work identify first post by if checking.
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/getting-first-only-post-through-wp-post-loop/#post-14279333)
 * Yes, that was clear, but the code was only partial, so it is difficult to help.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/getting-first-only-post-through-wp-post-loop/#post-14283120)
 * Your code will work as you expect in the right context even if it is hard to 
   read. If you are seeing more posts, some other code is responsible. Are you sure
   your code is on the right template?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Getting first only post through wp post loop’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/getting-first-only-post-through-wp-post-loop/#post-14283120)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
