Support » Fixing WordPress » custom post not showing content of post in columns

  • Resolved strik3r2

    (@strik3r2)


    Not sure if i have explained my problem sufficiently in the title but i am creating a 4 custom post type and defining them in my functions.php file. I have created 3 custom post types without a problem however on the forth one it will not display the content in the columns i have defined.

    these are my functions

    //add a filter and an action to the events custom post type
     add_filter('manage_edit-events_columns', 'events_edit_columns');
     add_action('manage_posts_custom_column', 'events_custom_columns');
    
    //edit events columns names
    	function events_edit_columns ($columns) {
    		$columns = array(
    				"cb" => "<input type=\"checkbox\" />",
    				"title" => "Event Name",
    				"type" => "Event Type",
    				"location" => "Location",
    				"dates" => "Date",
    				"time" => "time",
    				"image" => "Image"
    			);
    
    		return $columns;
    	}
    
    	//edit content for all the added columns
    	//for the events custom post type
    	function events_custom_columns ($column) {
    		global $post;
    
    		switch($column)
    		{
    			case "type":
    				$custom = get_post_custom();
    				echo $custom["events_type"][0];
    				break;
    			case "location":
    				$custom = get_post_custom();
    				echo $custom["events_location"][0];
    				break;
    			case "dates":
    				$custom = get_post_custom();
    				echo $custom['events_date'][0];
    				break;
    			case "time":
    				$custom = get_post_custom();
    				echo $custom['events_time'][0];
    				break;
    			case "image":
    				$custom = get_post_custom();
    				echo $custom['events_image'][0];
    				break;
    		}
    	}
Viewing 4 replies - 1 through 4 (of 4 total)
  • If this is a hierarchal post type(like pages) try changing this.

    add_action('manage_posts_custom_column', 'events_custom_columns');

    ..to..

    add_action('manage_pages_custom_column', 'events_custom_columns');

    ..and see if that helps.

    strik3r2

    (@strik3r2)

    ahh.. thanks so much.. worked like a charm.

    Read about a similar problem recently, sprung into my mind when i read your post.

    Happy i could help.. 😉

    Thank you so much! I have been searching for days on why my categories weren’t showing up.

    Works great now!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘custom post not showing content of post in columns’ is closed to new replies.