php – Customize List within Admin Panel – WordPress

Question:

i'm on a project, i need to make some changes right inside the wordpress panel. More specifically on a page that lists a specific post list.

  • I need to add a custom search field with a specific field.
  • I also need to add some more columns in the same table.

I checked the wordpress documentation . But it's something very superficial, not very explanatory.

Has anyone ever needed to do it?.

Thanks.

Answer:

See this example taken from codex, how you can add / manipulate columns:

/* Display custom column */
function display_posts_stickiness( $column, $post_id ) {
    if ($column == 'sticky'){
        echo '<input type="checkbox" disabled', ( is_sticky( $post_id ) ? ' checked' : ''), '/>';
    }
}
add_action( 'manage_posts_custom_column' , 'display_posts_stickiness', 10, 2 );

/* Add custom column to post list */
function add_sticky_column( $columns ) {
    return array_merge( $columns, 
        array( 'sticky' => __( 'Sticky', 'your_text_domain' ) ) );
}
add_filter( 'manage_posts_columns' , 'add_sticky_column' );

Reference : https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column

As for the custom search field, what type of information would you like to filter / search?

Anyway see the link below for some examples of possible filters: https://www.sitepoint.com/customized-wordpress-administration-filters/

Scroll to Top