• Was wondering if something changed in the most recent version of WordPress. I have a number of custom post types and I’m creatingcustom columns for them on thier respective edit screens. I was following a tutorial and for some reason the action hook “manage_posts_custom_column” wouldn’t work but “manage_pages_custom_column” did. Is there any reason for this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Displaying the data is a two step process. First you need to create the columns (for each individual post type), and then you need to populate it (using the generic ‘post’ to do all post types at once).

    For example, a custom post type ‘News’ would display an ID column as follows –

    // Create an ID Column in the News post type
    add_filter('manage_edit-news_columns', 'show_news_columns', 4);
    function show_id_column($defaults){
    	$defaults['show_item_ids'] = __('ID');
    	return $defaults;
    }
    
    // Populate the ID column in all Post types
    add_action('manage_posts_custom_column', 'fill_custom_columns', 4, 2);
    function fill_custom_columns($column_name, $id){
    	if($column_name === 'show_item_ids'){
    		echo (int)$id;
    	}
    }
    Thread Starter Manny Fleurmond

    (@funkatronic)

    I actually found a solution to my problem. The post type I had trouble with was set to hierarchical, which made WordPress treat it like a page instead of a post. Because of that, “manage_posts_custom_column” wouldn’t work.

    Thanks for the info.

    custom post type hierarchical: true -> manage_page_custom_column

    custom post type hierarchical: false -> manage_post_custom_column

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

The topic ‘manage_posts_custom_column vs manage_pages_custom_column’ is closed to new replies.