/*
This is the taxonomy build, ready for copy pasting.
*/
add_action( 'init', 'agenda_taxonomy_options' );
function agenda_taxonomy_options() {
$name = 'agenda';
$post_type = 'agenda_posts';
register_post_type( $post_type, // This will be the postype!
array(
'label' => __( 'Agenda' ),
'labels' => array(
'name' => __( 'Agenda' ),
'singular_name' => __( 'Agenda item' ),
'add_new' => __( 'Item toevoegen' ),
'add_new_item' => __( 'Nieuw item' ),
'edit_item' => __( 'Wijzig item' ),
'new_item' => __( 'Nieuw item' ),
'all_items' => __( 'Alle items' ),
'view_item' => __( 'Bekijk items' ),
'search_items' => __( 'Zoek item' ),
'not_found' => __( 'Er zijn geen items gevonden' ),
'not_found_in_trash' => __( 'Geen item gevonden in de prullenbak' )
),
'public' => true,
'can_export' => true,
'show_ui' => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'exclude_from_search' => true,
//'menu_icon' => get_bloginfo('template_url').'/images/favicon.ico',
'hierarchical' => false,
'rewrite' => array( "slug" => "agenda" ), // Permalinks
'supports' => array(
'title',
),
'show_in_menu' => true,
) );
}
add_action("manage_agenda_posts_posts_custom_column", "agenda_columns");
function agenda_columns($column)
{
// Define
global $post, $blog_id;
switch ($column)
{
// ROW Description
case 'datum':
echo strftime(customStrftime('%A %e %B %Y om %H:%M'),get_post_meta($post->ID, 'event_date', true));
break;
}
}
add_filter("manage_edit-agenda_posts_columns", "agenda_columns_array");
function agenda_columns_array($columns)
{
$columns = array(
"cb" => "",
"title" => __("Item"),
"datum" => __("Datum / tijd"));
return $columns;
}
add_filter("manage_edit-agenda_posts_sortable_columns", "agenda_columns_sortable");
function agenda_columns_sortable($columns)
{
$columns['datum'] = 'event_date';
return $columns;
}
add_action( 'agenda_posts_order_by', 'agenda_columns_order_by' );
function agenda_columns_order_by( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
if( 'event_date' == $orderby ) {
$query->set('meta_key','event_date');
$query->set('orderby','meta_value_num');
}
}
add_filter( 'cmb2_meta_boxes', 'agenda_meta_boxes' );
function agenda_meta_boxes( array $meta_boxes ) {
$prefix = '';
$meta_boxes['agenda_posts_metabox'] = array(
'id' => 'agenda_posts_metabox',
'title' => __( 'Opties', 'cmb2' ),
'object_types' => array( 'agenda_posts' ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => 'Datum / tijd',
'id' => 'event_date',
'type' => 'text_datetime_timestamp',
),
array(
'name' => 'Korte titel',
'id' => 'short_title',
'type' => 'text',
),
)
);
return $meta_boxes;
}
?>
add_action( 'init', 'diner_taxonomy_options' );
function diner_taxonomy_options() {
$name = 'diner';
$post_type = 'diner_posts';
register_post_type( $post_type, // This will be the postype!
array(
'label' => __('Menukaart'),
'labels' => array(
'name' => __('Menukaart'),
'singular_name' => __('Item'),
'add_new' => __('Item toevoegen'),
'add_new_item' => __('Nieuw item'),
'edit_item' => __('Wijzig item'),
'new_item' => __('Nieuw item'),
'all_items' => __('Alle items'),
'view_item' => __('Bekijk items'),
'search_items' => __('Zoek item'),
'not_found' => __('Er zijn geen items gevonden'),
'not_found_in_trash' => __('Geen item gevonden in de prullenbak')),
'public' => true,
'can_export' => true,
'show_ui' => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'exclude_from_search' => true,
//'menu_icon' => get_bloginfo('template_url').'/images/favicon.ico',
'hierarchical' => false,
'rewrite' => array("slug" => "diner"), // Permalinks
'supports' => array(
'title',
'editor'
),
'show_in_menu' => true,
));
}
add_action("manage_diner_posts_posts_custom_column", "diner_columns");
function diner_columns($column)
{
// Define
global $post, $blog_id;
$home_url = get_home_url();
switch ($column)
{
// ROW Description
case 'datum':
echo strftime(customStrftime('%A %e %B %Y om %H:%M'),get_post_meta($post->ID, 'date', true));
break;
}
}
add_filter("manage_edit-diner_posts_columns", "diner_columns_array");
function diner_columns_array($columns)
{
$columns = array(
"cb" => "",
"title" => __("Item"),
"datum" => __("Datum / tijd"));
return $columns;
}
add_filter("manage_edit-diner_posts_sortable_columns", "diner_columns_sortable");
function diner_columns_sortable($columns)
{
$columns['datum'] = 'datum';
return $columns;
}
add_action( 'diner_posts_order_by', 'diner_columns_order_by' );
function diner_columns_order_by( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
if( 'event_date' == $orderby ) {
$query->set('meta_key','event_date');
$query->set('orderby','meta_value_num');
}
}
add_filter( 'cmb2_meta_boxes', 'diner_meta_boxes' );
function diner_meta_boxes( array $meta_boxes ) {
$prefix = '';
$meta_boxes['diner_posts_metabox'] = array(
'id' => 'diner_posts_metabox',
'title' => __( 'Opties', 'cmb2' ),
'object_types' => array( 'diner_posts' ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => 'Datum / tijd',
'id' => 'date',
'type' => 'text_date_timestamp',
),
array(
'name' => 'Menu 2',
'id' => 'menu2',
'type' => 'wysiwyg',
),
)
);
return $meta_boxes;
}
?>