apply_filters( 'list_table_primary_column', string $default, string $context )

Filters the name of the primary column for the current list table.


Description Description


Parameters Parameters

$default

(string) Column name default for the specific list table, e.g. 'name'.

$context

(string) Screen ID for specific list table, e.g. 'plugins'.


Top ↑

Source Source

File: wp-admin/includes/class-wp-list-table.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
4.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Andrija Naglic

    A simple example for Users table and CPT table

    
    function my_list_table_primary_column( $default, $screen ) {//                                                             Alter the primary column in edit.php table(s)
    
    	// if we want the 'Name' column to be the primary column, on Users screen
        if ( 'users' === $screen ) {
            $default = 'name';
        }
        
    	// if we want to set the primary column for CPT
        if ( 'edit-my_custom_post_type' === $screen ) {
            $default = 'my_custom_column_name';
        }
        
        return $default;
    }
    add_filter( 'list_table_primary_column', 'my_list_table_primary_column', 10, 2 );
    

    For further management of columns, check:

    https://developer.wordpress.org/reference/hooks/manage_post_type_posts_columns/
    To add/remove/rename columns

    https://developer.wordpress.org/reference/hooks/manage_post-post_type_posts_custom_column/
    To set the custom column values

You must log in before being able to contribute a note or feedback.