Tag: Custom Post Type

WordPress: Sortable Custom Columns

| 2 comments

This entry is part of my WordPress development series, providing tutorials on specific things you can do in WordPress. Read some more?

Continuing on from the previous tutorial where we added custom columns, we are now going to make these columns sortable like the regular default columns in WordPress (such as post/page title and publish date).

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.

From the last tutorial, I have already created my custom columns for my custom post type “Cats”. So first we have to tell WordPress to make our columns sortable using the function add_filter().

// Make columns sortable
add_filter( 'manage_edit-cf_cats_sortable_columns', 'cats_sortable_cols' );

function cats_sortable_cols( $columns ) {

	$columns['age'] = 'age';
	$columns['toy'] = 'toy';

	return $columns;
}

Read More »

WordPress: Adding Custom Columns

| 0 comments

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().

Read More »

WordPress: Create a Custom Post Type

| 0 comments

This is the first entry of my WordPress development series, providing tutorials on specific things you can do in WordPress. Stay tuned for more!

I have been working with Custom Post Types recently, so I want to start off the series with them. Custom Post Types are just like Pages and Posts, but you can call them whatever you like. They can be used for a variety of content such as Events, Bands, a Book database, Cars, Recipes… if you can think of it, it can probably be a Custom Post Type! They are handy because you can separate them from your regular blog Posts, they can be integrated into your themes and plugins, and even created just by using functions.php.

For simplicity, we will create our Custom Post Type 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. I’m going to be creating a post type called Cats.

Read More »