how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?

How add_action("manage_posts_custom_column", "custom_callback_fun01"); relate to add_filter("manage_{xxxx-xxx}_columns", "cusotm_callback_fun02" );?

How do they both work together? By using these both we add custom columns to custom posts types and show date, for example featured images in featured columns.
Here is my code example, it works great but I’m a little confused on how the filter works with action hook?

//slides
add_filter("manage_edit-slides_columns", "edit_slides_columns" );
add_action("manage_posts_custom_column", "custom_slides_columns");

function edit_slides_columns($slides_columns){
        $slides_columns = array(
                "cb" => "<input type="checkbox" />",
                "title" => "Title",
                "slider_image" => "Featured Image",
                "date" => "Date"
        );
        return $slides_columns;
}

function custom_slides_columns($slides_column){
        global $post;
        switch ($slides_column)
        {
        case "slider_image":
                if(has_post_thumbnail()) {
                 //get atachment url
                 $img_url = wp_get_attachment_url(get_post_thumbnail_id(),'full'); //get full URL to image
                 //resize & crop the featured image
                 $featured_image = $featured_image = aq_resize( $img_url, 80, 80, true );
                echo '<img src="'. $featured_image .'" />';
                } else { echo '-'; }
        break;
        }

}

1 Answer
1

add_filter("manage_{xxxx-xxx}_columns", "cusotm_callback_fun02" ); is used to add the column itself to the list of columns for that post_type. add_action("manage_posts_custom_column", "custom_callback_fun01"); adds the actual content of the column per post.

Leave a Comment