Back to Top

To get Last auto increment id in WordPress

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 and want to get the last auto increment id of table before apply insert query.

I have tried with LAST_INSERT_ID() function but it was not working so i have checked in mysql official site and get that it’s used for to get auto increment value of most recently executed INSERT statement

Here, I am going to share the solution of this issue. Let’s check the code:

Above query will get auto increment value from information_schema. And then just increase it’s value to 1 to generate next id.

You may like other articles:

Remove suffix from taxonomies in WordPress
To change content Type of mail in WordPress
WordPress site into maintenance mode Without Plugin

That’s was so simple to get auto increment id from table. Share your thoughts if you any other simple way to get auto increment value from table.

If you have any query or question,tell us in the comment section :). Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to Count Number of Columns in MySQL

Posted on 6 years ago


How dialog error message works in xCart?

Posted on 5 years ago


Learn about InnoDB MySQL Storage Engine

Posted on 7 years ago


How to get Last Post in WordPress

Posted on 6 years ago