WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;
        }

}
share|improve this question

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.