Support

Account

Home Forums General Issues ACF Column in Custom Post Type

Helping

ACF Column in Custom Post Type

  • Wondering if anyone can tell me why this doesn’t work. It should show the acf start_date and end_date columns in my custom post type of ad? Thanks for any assistance! Added to functions.php:

    [code]
    // Add columns to ads post list
    function add_acf_columns ( $columns ) {
    $columns = array(
    ‘title’ => ‘Title’,
    ‘start_date’ => ‘Starts’,
    ‘end_date’ => ‘Ends’,
    ‘date’ => ‘Date’,
    );
    return $columns;
    }

    // Add columns to ads post list
    function ads_custom_column ( $column ) {
    global $post;
    if ($column == ‘start_date’) {
    the_field(‘start_date’);
    } elseif ($column == ‘end_date’) {
    the_field(‘end_date’);
    }
    }
    add_action(“manage_posts_custom_column”, “ads_custom_column”);
    add_filter(“manage_edit-ad_columns”, “add_acf_columns”);
    [/code]

  • The hooks for the functions should be manage_edit-{$CUSTOM_POST_TYPE}_columns for the columns and manage_{$CUSTOM_POST_TYPE}_posts_custom_column for the content in the columns.

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

The topic ‘ACF Column in Custom Post Type’ is closed to new replies.