Administration columns

Radoslav Georgiev edited this page Oct 21, 2018 · 3 revisions


Some of the locations of Ultimate Fields allow you to add additional columns to the listings of the types they are associated with.

  • The Post Type location allows you to add columns to post listing screens.
  • The Taxonomy location allows you to add columns to taxonomy lists.
  • The User location allows you to add additional columns to user lists.

Adding additional columns to those listings/tables can let users get a better and quicker overview without having to enter idividual editing screens. For example, if you create a new Event post type, it would probably have "Event Start" and "Event End" fields associated with it. Since this is core information about the event, you might want to display it in the table.


In the UI

go to the "Columns" tab of any of the supported locations and add the columns, which you would like to use. For each column you can select:

  1. The field whose values should be displayed in the column.
  2. A position:
  • append will add the column at the end of the table
  • prepend will add the column in the absolute beginning of the table
  • after title will display the column with high priority after the title, but will not move the title to the right.
  1. If you want the column to be sortable or not.


You can use the admin_columns argument for the $args array or the add_admin_columns method of the location. Both of them expect a new Ultimate_Fields\Admin_Column instance.

To create a new column you can use the static create method:

$column = Admin_Column::create( 'event_start' );

Then you can use the following methods to set it up:

// Make the column sortable

// Set the position to `prepend`

// Set the position to `after_title`

// Use a custom callback to format the output of the column
$column->set_callback( 'my_formatting_function' );

function my_formatting_function( $value, $location, $item_id ) {
  // Do some formatting here
  return $value;

Each of the methods returns the column, so you can keep on using method chaining.

A complete example would look like this:

$container->add_location( 'post_type', 'event', array(
	'admin_columns' => array(
		Admin_Column::create( 'event_start' )
		Admin_Column::create( 'event_end' )

or like this if you are manually creating the location:

use Ultimate_Fields\Location;
use Ultimate_Fields\Admin_Column;

$location = new UF\Location\Post_Type( 'event' );

	Admin_Column::create( 'event_start' )
	Admin_Column::create( 'event_end' )

$container->add_location( $location );
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.