Last Record from loop in WordPress

by Bhumi // Oct 28,2012 // 2 comments

lr_wp

Here I come with quick but useful tips in wordpress.Recently I have upgraded my blog theme and I wanted to make some changes on last post found in loop on the last page.So I thought is it quite difficult to get last post?

No,Its not difficult and specifically in wordpress if you have good knowledge of wordpress core variables and functions so simply place explained code in below.

Let’s have a look into the condition which compares the total number of posts to the current post number:

Here, Wp_query property is used to count the number of posts and $wp_query->current_post gives us the current loop number.$wp_query->post_count will give a count of posts.

That’s it.It is so simple. Now you can make layout changes for last record of loop.

Thanks for reading and feel free to share your thoughts, don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

RELATED POST

To get Last auto increment id in WordPress

In this quick article, we will see how to get last auto increment id from table in WordPress. Recently I was working on plugin development READ MORE

Cookie Free domain in WordPress

Nowadays,optimization of site is most important and it’s good idea to use cookie free domains for static content in WordPress.Static contents are like images, JavaScripts READ MORE

Disable Post Revisions in WordPress

As i have explained yesterday in post POST AUTOSAVE INTERVAL IN WORDPRESS,When you add/edit the post or pages, wordpress automatically save your content in database READ MORE

Post Autosave Interval in WordPress

While you write a post in WordPress from admin,WordPress autosave the post with in every interval using AJAX call as a revision.Default interval set by READ MORE

ColorDots to highlight Event in FullCalendar

Here I am going to explain how to add colordots to highlight event in Full Calendar. Few months ago, I have used Full Calendar for READ MORE

Feedback 2

  1. With bountiful of new features and bug fixes, WordPress 3.5 surely made some remarkable improvements in the platform. The new update will definitely help WordPress to retain its throne in future. Kudos for the work of core developement team.

Leave a Reply

Your email address will not be published. Required fields are marked *


four + 5 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">