Created
October 22, 2018 17:44
-
-
Save ellegaarddk/363356ce453b176c247b1b93b594f462 to your computer and use it in GitHub Desktop.
creating custom post type for frontpage slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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ø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