Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
December 17, 2017 at 11:31 pm #889852
Hi guys!
I used CPT UI and ACF to create a CPT with a few custom fields. I now would love to add those columns to my admin post page for that custom post.I wrote adjusted the following code:
// Tabellenkopf und -fuß um Felder erweitern add_filter('manage_edit-juschu_imp_kundnrs','kb_edit_admin_kundnrs') ; function kb_edit_admin_kundnrs($kundnrs) { $kundnrs = array( 'cb' => '<input type="checkbox" />', 'title' => __('Title'), 'kundnr' => Kundennummer, 'author' => __('Author'), 'comments' => '<span class="vers comment-grey-bubble" title="' . __( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>', 'date' => __('Date') ); return $kundnrs; } // Inhalte aus benutzerdefinierten Feldern auslesen und den Spalten hinzufügen add_action ('manage_juschu_imp_posts_custom_kundnr','kb_post_custom_kundnrs'); function kb_post_custom_kundnrs($kundnr) { global $post; $custom = get_post_custom(); switch ($kundnr) { case "kundnr": $kb_field = get_post_meta($post->ID, 'knr', true ); echo $kb_field; break; } } // Hinzugefügte Spalten sortierbar machen add_filter( 'manage_edit-juschu_imp_sortable_kundnrs', 'kb_post_sortierbare_kundnrs' ); function kb_post_sortierbare_kundnrs( $kundnrs ) { $kundnrs['kundnr'] = 'knr'; return $kundnrs; }
Which i got here: https://blog.kulturbanause.de/2016/11/wordpress-admin-columns-um-custom-fields-erweitern/
But I can’t get it to work. I am working on my localhost, so i cant provide you with a link. Can you please tell me where to post that code? functions.php didn_t work.
Thank you.
- This topic was modified 6 years, 11 months ago by fabienneRedUmb.
December 18, 2017 at 9:59 pm #890263Hey,
Please try changing the code to following one
// Tabellenkopf und -fuß um Felder erweitern add_filter('manage_edit-juschu_imp_columns','kb_edit_admin_kundnrs') ; function kb_edit_admin_kundnrs($kundnrs) { $kundnrs = array( 'cb' => '<input type="checkbox" />', 'title' => __('Title'), 'kundnr' => Kundennummer, 'author' => __('Author'), 'comments' => '<span class="vers comment-grey-bubble" title="' . __( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>', 'date' => __('Date') ); return $kundnrs; } // Inhalte aus benutzerdefinierten Feldern auslesen und den Spalten hinzufügen add_action ('manage_juschu_imp_posts_custom_column','kb_post_custom_kundnrs'); function kb_post_custom_kundnrs($kundnr) { global $post; $custom = get_post_custom(); switch ($kundnr) { case "kundnr": $kb_field = get_post_meta($post->ID, 'knr', true ); echo $kb_field; break; } } // Hinzugefügte Spalten sortierbar machen add_filter( 'manage_edit-juschu_imp_sortable_columns', 'kb_post_sortierbare_kundnrs' ); function kb_post_sortierbare_kundnrs( $kundnrs ) { $kundnrs['kundnr'] = 'knr'; return $kundnrs; }
Best regards,
YigitDecember 20, 2017 at 6:48 pm #890901Thank you, that helped!
December 20, 2017 at 9:46 pm #890930 -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- The topic ‘Add Custom Columns to Admin Tabe of Custom Posts’ is closed to new replies.