Home Forums Backend Issues (wp-admin) Add checkbox to admin column


Add checkbox to admin column

  • I am trying to add columns to my admin area from a custom post type.

    The code below successfully adds two columns, the ‘Sale or Charter’ column returns the correct value, but the ‘featured’ returns the value ‘array’ rather than ‘yes’ or blank. The first is a radio button the second is a checkbox.

    What am I doing wrong?

    Secondly, is it possible to actually add the checkbox in the admin column? In the same way you have a star for featured products in WooCommerce.

    Alternatively adding the option to the quick edit area.

    Any help greatly appreciated.

     * Add columns to Yacht Listings
     function add_acf_columns ( $columns ) {
       return array_merge ( $columns, array ( 
    	 'featured' => __ ( 'Featured' ),
    	 'sale_or_charter'   => __ ( 'Listing Type' ) 
       ) );
     add_filter ( 'manage_yachts_posts_columns', 'add_acf_columns' );
     * Add columns to yacht post list
     function yachts_custom_column ( $column, $post_id ) {
       switch ( $column ) {
    	 case 'featured':
    	   echo get_post_meta ( $post_id, 'featured', true );
    	 case 'sale_or_charter':
    	   echo get_post_meta ( $post_id, 'sale_or_charter', true );
     add_action ( 'manage_yachts_posts_custom_column', 'yachts_custom_column', 10, 2 );
  • ACF stores chaeckbox fields as serialized arrays.

    echo implode(', ', get_post_meta ( $post_id, 'sale_or_charter', true ));
  • Hi John

    I am very sorry, I did not see this reply until just now!

    I found a solution but not a great one, so I will try this.


Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.