• Rubel

    (@bluemoon86)


    Code link
    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 to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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

    (@bluemoon86)

    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.

    Yes, that was clear, but the code was only partial, so it is difficult to help.

    Moderator bcworkz

    (@bcworkz)

    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.