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 it.it 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

Overview of Views in MySQL

Posted on 1 year ago

Bhumi

What is Final keyword in PHP

Posted on 6 years ago

Bhumi

How to use PHP Method Chaining?

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2012

Posted on 6 years ago

Bhumi