pods_ui()

Easily create content admin screens with in-depth customization.

Set up the PodsUI class object.

Easily create content admin screens with in-depth customization. This is the primary interface function that Pods runs off of. It’s also the only function required to be run in order to have a fully functional Manage interface.

Please note: The options listed here are still undergoing cleanup from our old Pods 1.x documentation.

Function Definition

function pods_ui ( $obj, $deprecated = false )

Source File:/pods/includes/classes.php

Since: 2.0

Parameters

PARAMETERTYPEDETAILS
$obj(array|string|Pods)(optional) Configuration options for the UI
$deprecated(boolean)(optional) Whether to enable deprecated options (used by pods_ui_manage)

Additional Parameter Options

OPTIONTYPEDEFAULTDETAILS
pod(string)nullPod to use in $object (ONLY works if passing as an array / querystring instead of an $object)
items(string)Pod Type with underscores replaced as spaces and run through ucwords()The title to show on the Manage screen: “Manage $title”
item(string)Pod Type with underscores replaced as spaces and run through ucwords()What to call this item in various messages: “Add New $item”, “$item not found, cannot delete.”, “$item not found, cannot edit.”
num(string)nullIf you have multiple manage interfaces intertwined, you can provide this as a unique identifier
id(string)$_GET[’id’.$object->ui[’num’]You can override the ID value here, which ignores whatever is in the URL at the time
fields(array)nullSet of arrays of fields to use for manage/search/add/edit/duplicate/reorder/export
action(string)$_GET[’action’.$object->ui[’num’]You can override the action value here, which ignores whatever is in the URLat the time
label(array)nullCustom label array, for add/edit/duplicate submit button text, and for add_new/reorder link text in heading
reorder(array)nullOptions for on/limit/orderby/orderby_dir/sql for the Reorder functionality
orderby(string)t.name ASCWhat column to ORDER BY, within findRecords()
sortable(string)nullIf this variable is defined, it will TURN OFF the ability to sort by fields in the manage screen
limit(integer)25How many records to show per page, within findRecords(), can be overridden by Show per page option listed next to pagination
where(array)nullHow to restrict the manage/reorder table list
sql(string)nullYou can provide an SQL statement to override the default SQL generated in findRecords()
search(boolean)nullWhether or not to show the search box above the Manage screen when listing items. Set to ‘false’ to turn off
search_across(boolean)nullWhether or not to search across all fields (excluding pick fields, which you can enable in ‘search_across_picks’). Set to ‘false’ to turn off
search_across_picks(boolean)nullWhether or not to search across all pick fields. Set to ‘true’ to turn on
filters(array)nullAdditional filters to show for a Pod in Search area
custom_filters(string)nullCustom HTML to appear in the Search Area (before Filters and Search box)
actions_disabled(array)nullAn array of actions to disable, if you supply ‘add’ and/or ‘edit’ it will also disable the link on the Manage screens
actions_hidden(array)nullAn array of actions to hide, if you supply ‘add’ and/or ‘edit’ it will also hide the link on the Manage screens
actions_custom(array)array()An array of custom actions and corresponding functions to run, they will appear under Pod Items next to Edit and Delete, label shows up with underscores replaced as spaces and run through ucwords(): $action=>$function. Example usage: actions_custom = array( ‘your_action’ => array( ‘label’ => ‘Your Action Name’, ‘callback’ => ‘your_callback_function’ ) );
action_after(array)nullArray of actions to go to after add/edit/delete, sets the action to set in the URL after saving an item (defaults to form, but you can set this to ‘manage’ to send back to the Manage panel)
action_links(array)nullArray of custom links to go to for add/edit/duplicate/view/delete/reorder instead of the defaults
wpcss(string)nullIf this variable is defined (even if defined as 0), Pods UI will output the required CSS to make the UI output look like WP – BE SURE TO HAVE “!important” IN YOUR CSS OR THIS WILL OVERRIDE YOUR PREVIOUSLY DECLARED CSS STYLES

Returns

(PodsUI) The PodsUI object.

Examples

Example 1

Pass an array to pods_ui() with the name of the Pod in the ‘pod’ key.

<?php 
$ui = array(
    'pod' => 'your_pod',
    'title' => 'My Pod',
    'add_fields' => array( 'name', 'body' ),
    'edit_fields' => array( 'name', 'body', 'approved' )
);

pods_ui( $ui );

Example 2

Pass an array to pods_ui() with a Pods object as the ‘pod’ key.

<?php
$object = pods( 'yourpod' );

$ui = array(
    'pod' => $object;
    'title' => 'My Pod',
    'add_fields' => array( 'name', 'body' ),
    'edit_fields' => array( 'name', 'body', 'approved' )
);

pods_ui( $ui );

Example 3

Pass a Pods object to pods_ui();  you can set the Pods->ui array directly on the Pods object.

<?php
$object = pods( 'yourpod' );

$object->ui = array(
    'title' => 'My Pod',
    'add_fields' => array( 'name', 'body' ),
    'edit_fields' => array( 'name', 'body', 'approved' )
);

pods_ui( $object );

Customizing the fields on various content management screens

Programmatically exclude or customize the fields listed on the add, edit, and manage ui screens (Thanks to Kamil Grzegorczyk for this practical example and the great pods_ui() reference on LOWGRAVITY.PL)

<?php
$object = pods('name_of_pod');
$fields = array();
 
// iterate through the fields in this pod
foreach($object->fields as $field => $data) {
    $fields[$field] = array('label' => $data['label']);
}
 
// exclude a specific field by field name
unset($fields['field_name']);
 
// customize the label for a particular field
$fields['field_name'] = array( 'label' => 'some_different_label');
 
// hide some fields on edit screen but still have them on the add screen
$edit_fields = $fields;
unset($edit_fields['field_name']);
 
// fields visible on manage screens
$manage_fields = array('few', 'manage', 'fields');
 
$object->ui = array(
    'fields' => array(
        'add' => $fields,
        'edit' => $edit_fields,
        'manage' => $manage_fields,
    ),
    //other parameters
);
 
pods_ui($object);

Parameters deprecated in 2.x

  • title
  • label
  • label_add
  • label_edit
  • label_duplicated
  • columns
  • reorder_columns
  • add_fields
  • edit_fields
  • duplicate_fields
  • session_filters
  • user_per_page
  • user_sort
  • custom_list
  • custom_reorder
  • custom_add
  • custom_edit
  • custom_duplicate
  • custom_delete
  • custom_save
  • custom_actions
  • edit_link
  • view_link
  • duplicate_link
  • reorder
  • reorder_sort
  • reorder_limit
  • reorder_sql
  • sort
  • edit_where
  • duplicate_where
  • delete_where
  • reorder_where
  • search
  • disable_actions
  • hide_actions

Other Helpful Documentation on Code Reference

Action Hook Reference

Field Functions

Field handling with Pods

Filter Reference

General Functions

Media Functions

Media handling functions in Pods

Pods Blocks API

Pods 2.8 introduces a new API for creating blocks with PHP.

Pods DFV JS API

The DFV JS API allows you to interact with the forms that Pods displays.

Pods REST API Endpoints

The Pods Admin REST API Endpoints for managing configurations.

Pods WP-CLI Commands

How to use the Pods CLI to access wp pods and wp pods api

pods_api()

We are working hard on our new code reference site. Until then this section will remain unavailable. Thank you for your patience.

pods()

Set up the Pods class object for a specific pod.

Registering Configurations

Registering Configurations with Pods is possible through file-based or code-based registration.

WPGraphQL Integration

The WPGraphQL integration allows Pods content types and their fields to be discoverable by the WPGraphQL plugin.