WordPress: Adding Custom Columns
This entry is part of my WordPress development series, providing tutorials on specific things you can do in WordPress. Read some more?
This tutorial is going to show you how to take the metadata stored in your custom meta box (or boxes) from your custom post type and display it as columns on the browse or “All” page – for my custom post type, that would be the page “Cats”. This is a great way to show some extra information about your custom posts at once without having to go to each individual post. Continuing on from the previous tutorial, I am going to display the age and favourite toy metadata that I stored for my cat Azaezel.
For simplicity, we will continue to work in our functions.php file. You can edit this file by going to Appearance > Editor in your WordPress admin panel, or using a text editor with FTP.
To begin, we first have to create the columns. We do this by using the function add_filter()
.