David
David

Reputation: 85

Last Post Function in wordpress

I made my website http://test.costa.io/?page_id=4, with wordpress and I put here all my post. The problem is that I want to have a function to check if its the last post, and if it's so dont put the /hr/.

I tried with the function more_post() and last_post but didn't make it work.

This is the code of the plugin I use to get all the post in the web :

http://pastebin.com/Qv9Ff2T7

Upvotes: 0

Views: 170

Answers (2)

David
David

Reputation: 85

Ok I make it work changing the way I did it, still the count was a good way to do it, so ill give u the credit for it. Thanks everyone

Upvotes: 0

xjmdoo
xjmdoo

Reputation: 1736

You can get the number of posts you have by count($posts) and then add a counter variable in the foreach loop. When the counter is equal to the number of posts you know that it's the last post, so don't output the hr.

Upvotes: 1

Related Questions