How to add custom column in WordPress post

How to add custom column in WordPress post

This post has been viewed 122 times.

In this tutorial, we would be learning on how to add custom column in WordPress post.

If you are creating a plugin that is meant to be used on posts, then you might need this function.

You might have noticed that there are six (6) default columns in the WordPress posts table.

The goal of this tutorial is to add another column that will show the date when the post was last modified.

What you’ll need:

  • A WordPress website.

Step 1: Setup the column header.

This will show the name that will appear as the header in the table. It will also hook our function to WordPress.

In this example, we would be naming our custom column as Last Modified Date.

Step 2: Setup the column content.

Now that we have the header, we must put something in the table data. It can be anything you want.

You can even use the $post_ID variable to uniquely identify each post.

We must put the condition on where would we put the content. It must be the same on the custom column name that we have created.

If you do not do this then it will be added to all custom column available and might conflict with other plugins with the same capabilities.

In this example, we would be showing a column composed of the date when the post was last modified.

Complete Code:

That’s it, we have now added the 7th column on the WordPress post page that shows when the post was last modified.

Hello, I am a freelance website and mobile application developer. I am also the owner of this website, so if you have any projects for me you can contact me at [email protected] or use the contact page. When I’m not doing some work, I can be found watching Anime/Asian Dramas/American TV Series, playing computer games, and writing tutorials on this website. I run the program repeatedly hoping the error won’t show up next time.