Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
creating custom post type for frontpage slider
<?php
/* creating custom post type for frontpage slider
* By ellegaard ID - www.eid.dk
*/
add_action('init', 'create_frontpagepic');
function create_frontpagepic() {
$feature_args = array(
'labels' => array(
'name' => __( 'Forsidebilleder' ),
'singular_name' => __( 'Forsidebillede' ),
'add_new' => __( 'Tilf&oslash;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");
//* creating admin view */
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));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.