Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mishterk
Last active January 23, 2024 14:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mishterk/6f69aece97d86c6174553558fc47c603 to your computer and use it in GitHub Desktop.
Save mishterk/6f69aece97d86c6174553558fc47c603 to your computer and use it in GitHub Desktop.
<?php
$post_type = 'my_post_type';
// Register the columns.
add_filter( "manage_{$post_type}_posts_columns", function ( $defaults ) {
$defaults['custom-one'] = 'Custom One';
$defaults['custom-two'] = 'Custom Two';
return $defaults;
} );
// Handle the value for each of the new columns.
add_action( "manage_{$post_type}_posts_custom_column", function ( $column_name, $post_id ) {
if ( $column_name == 'custom-one' ) {
echo 'Some value here';
}
if ( $column_name == 'custom-two' ) {
// Display an ACF field
echo get_field( 'my_acf_field', $post_id );
}
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment