_x('Films', 'post type general name'),
'singular_name' => _x('Film', 'post type singular name'),
'add_new' => _x('Add New Film', 'Film item'),
'add_new_item' => __('Add New Film'),
'edit_item' => __('Edit Film'),
'new_item' => __('New Film'),
'view_item' => __('View Film'),
'search_items' => __('Search Films'),
'not_found' => __('No Films found'),
'not_found_in_trash' => __('No Films found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array("slug" => "films"),
'menu_position' => 3,
'supports' => array('title','editor','thumbnail','excerpt'),
'menu_icon' => 'dashicons-format-video',
);
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(array(
'label' => 'Cover',
'id' => 'secondary-image',
'post_type' => 'film'
)
);
new MultiPostThumbnails(array(
'label' => 'Films Page Image',
'id' => 'secondary-image-2',
'post_type' => 'film'
)
);
}
register_post_type( 'Film' , $args );
}
add_action('init', 'ph_films');
register_taxonomy("type", array("film"), array("hierarchical" => true, "label" => "Types", "singular_label" => "Type", "rewrite" => true));
add_action("admin_init", "phf_meta_init");
function phf_meta_init(){
add_meta_box("phf_year", "Year", "phf_year", "Film", "side", "high");
add_meta_box("phf_video", "Videos", "phf_video", "Film", "side", "low");
add_meta_box("phf_credits", "Credits", "phf_credits", "Film", "advanced", "low");
add_meta_box("phf_publicity", "Publicity", "phf_publicity", "Film", "advanced", "low");
add_meta_box("phf_reviews", "Reviews", "phf_reviews", "Film", "advanced", "low");
add_meta_box("phf_featuring", "Featuring", "phf_featuring", "Film", "advanced", "low");
add_meta_box("phf_color", "Colors", "phf_color", "Film", "side", "low");
add_meta_box("phf_price", "Purchase Options", "phf_price", "Film", "side", "low");
//echo '';
}
function phf_year(){
global $post;
$custom = get_post_custom($post->ID);
$ph_year = $custom["ph_year"][0];
?>
ID);
$video = $custom["video"][0];
?>
ID);
$credits = $custom["credits"][0];
?>
ID);
$publicity = $custom["publicity"][0];
?>
ID);
$reviews = $custom["reviews"][0];
?>
ID);
$featuring = $custom["featuring"][0];
?>
ID);
$custom2 = get_post_custom($post->ID);
$custom3 = get_post_custom($post->ID);
$color = $custom["color"][0];
$color2 = $custom2["color2"][0];
$color3 = $custom3["color3"][0];
?>
ID);
$custom2 = get_post_custom($post->ID);
$custom3 = get_post_custom($post->ID);
$custom4 = get_post_custom($post->ID);
$price = $custom["price"][0];
$price2 = $custom2["price2"][0];
$price3 = $custom3["price3"][0];
$price4 = $custom4["price4"][0];
?>
Price: (no dollar sign)
Vendor/Distributor
post_type == 'film' ) {
if (isset( $_POST ) ) {
update_post_meta($post->ID, "ph_year", $_POST["ph_year"]);
update_post_meta($post->ID, "video", $_POST["video"]);
update_post_meta($post->ID, "credits", $_POST["credits"]);
update_post_meta($post->ID, "publicity", $_POST["publicity"]);
update_post_meta($post->ID, "featuring", $_POST["featuring"]);
update_post_meta($post->ID, "reviews", $_POST["reviews"]);
update_post_meta($post->ID, "color", $_POST["color"]);
update_post_meta($post->ID, "color2", $_POST["color2"]);
update_post_meta($post->ID, "color3", $_POST["color3"]);
update_post_meta($post->ID, "price", $_POST["price"]);
update_post_meta($post->ID, "price2", $_POST["price2"]);
update_post_meta($post->ID, "price3", $_POST["price3"]);
update_post_meta($post->ID, "price4", $_POST["price4"]);
}
}
}
add_action('manage_film_posts_custom_column', 'manage_film_columns', 10, 2);
function manage_film_columns($column_name, $id) {
global $wpdb;
switch ($column_name) {
case 'id':
echo $id;
break;
case "thumbnail":
echo the_post_thumbnail('small');
break;
case "cover":
echo MultiPostThumbnails::the_post_thumbnail_thumb('film', 'secondary-image');
break;
case 'images':
$num_images = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_parent = %d", $id ));
echo $num_images;
break;
default:
break;
}
}
add_filter('manage_edit-film_columns', 'add_new_film_columns');
function add_new_film_columns($film_columns) {
$new_columns['cb'] = '';
$new_columns['title'] = __('Film Name', 'column name');
$new_columns['images'] = __('Images');
$new_columns['thumbnail'] = __('thumbnail');
$new_columns['cover'] = __('cover');
$new_columns['date'] = __('Date', 'column name');
return $new_columns;
}
add_action( 'admin_head', 'phf_icons' );
function phf_icons() { ?>
query_vars["post_type"]) && $wp->query_vars["post_type"] != 'post' && $wp->query_vars["post_type"] != 'page') :
if ( file_exists(TEMPLATEPATH . '/' . $wp->query_vars["post_type"] . '.php') ) :
$ph_template = TEMPLATEPATH . '/' . $wp->query_vars["post_type"] . '.php';
elseif ( file_exists(TEMPLATEPATH . '/t_' . $wp->query_vars["post_type"] . '.php') ) :
$ph_template = TEMPLATEPATH . '/t_' . $wp->query_vars["post_type"] . '.php';
endif;
if(isset($ph_template)) :
if (have_posts()) :
include($ph_template);
die();
else :
$wp_query->is_404 = true;
endif;
endif;
endif;
}
?>