Snippets

Morten Larsen bEejn: Untitled snippet

Created by Morten Larsen last modified
add_action('init', 'create_frontpagepic');
function create_frontpagepic() {
	$feature_args = array(
		'labels' => array(
		'name' => __( 'Forsidebilleder' ),
	    'singular_name' => __( 'Forsidebillede' ),
	    'add_new' => __( 'Tilføj billede' ),
	    'add_new_item' => __( 'Tilføj nyt forsidebillede' ),
	    'edit_item' => __( 'Rediger Forsidebillede' ),
	    'new_item' => __( 'Tilføj nyt billede' ),
	    'view_item' => __( 'Vis billede' ),
	    'search_items' => __( 'Søg forside billeder' ),
	    'not_found' => __( 'Ingen forsidebilleder fundet' ),
	    'not_found_in_trash' => __( 'Ingen forsidebilleder fundet i skraldespand' )
		),
	    'public' => true,
	    'show_ui' => true,
	    'capability_type' => 'post',
	    'hierarchical' => false,
	    'rewrite' => true,
	    'menu_position' => 20,
	    'supports' => array('title', 'thumbnail')
	  );
	  register_post_type('feature',$feature_args);
	}
	add_filter("manage_feature_edit_columns", "feature_edit_columns");

function feature_edit_columns($feature_columns){
   $feature_columns = array(
      "cb" => "<input type=\"checkbox\" />",
      "title" => "Title"
   );
  return $feature_columns;
}
	
add_filter('manage_posts_columns', 'add_img_column');
add_action('manage_posts_custom_column', 'manage_img_column', 10, 2);

function add_img_column($columns) {
    $columns['img'] = __('Thumbs');
    return $columns;
}

function manage_img_column($column_name, $post_id) {
    if( $column_name == 'img' ) {
        echo get_the_post_thumbnail($post_id, array(200,50));
    }
}

Comments (1)