There are many great code snippets in their Gitlab. You might find more on their…
Add custom field as column for admin table for a custom post type
// Add the custom columns to the book post type:
add_filter( 'manage_ausstellung_posts_columns', 'set_custom_edit_ausstellung_columns' );
function set_custom_edit_ausstellung_columns($columns) {
//unset( $columns['author'] );
$columns['enym_artist'] = __( 'Künstler', 'enym' );
return $columns;
}
// Add the data to the custom columns for the book post type:
add_action( 'manage_ausstellung_posts_custom_column' , 'custom_ausstellung_column', 10, 2 );
function custom_ausstellung_column( $column, $post_id ) {
switch ( $column ) {
/*
case 'enym_artist' :
$terms = get_the_term_list( $post_id , 'book_author' , '' , ',' , '' );
if ( is_string( $terms ) )
echo $terms;
else
_e( 'Unable to get author(s)', 'your_text_domain' );
break;
*/
case 'enym_artist' :
echo '<a href="edit.php?s='.urlencode(get_post_meta( $post_id , 'enym_artist' , true )).'&post_status=all&post_type=ausstellung">'.get_post_meta( $post_id , 'enym_artist' , true ).'</a>';
break;
}
}
Dieser Beitrag hat 0 Kommentare