<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function get_calender_events() { $params = array(); /*Get current date*/ $current_date = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key = "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...
register_taxonomy(
'cv-templates_categories',
'cv-templates',
array(
'labels' => array(
'name' => 'CV Templates Categories',
'add_new_item' => 'Add New CV Templates Category',
'new_item_name' => "New CV Templates Category"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'hasArchive' => true
)
);
register_taxonomy
(
'cv-templates_tags',
'cv-templates',
array(
'labels' => array(
'name' => 'CV Templates Tag',
'add_new_item' => 'Add New CV Templates Tag',
'new_item_name' => "New CV Templates Tag"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'hasArchive' => true
)
);
register_post_type('cv-templates', array(
'labels' => array(
'name' => 'CV Templates',
'singular_name' => 'CV Templates',
'add_new' => 'Add New',
'add_new_item' => 'Add New CV Templates',
'edit' => 'Edit',
'edit_item' => 'Edit CV Templates',
'new_item' => 'New CV Templates',
'view' => 'View',
'view_item' => 'View CV Templates',
'search_items' => 'Search CV Templates',
'not_found' => 'No CV Templates found',
'not_found_in_trash' => 'No CV Templates found in Trash',
'parent' => 'Parent CV Templates'
),
'public' => true,
'menu_position' => 5,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'taxonomies' => array('CV Templates Category', 'CV Templates Post_tag'),
'rewrite' => array('slug' => 'cv-templates'),
'query_var' => true,
'has_archive' => true,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',)
)
);
function add_tags_categories() {
register_taxonomy_for_object_type('CV Templates Category', 'cv-templates');
register_taxonomy_for_object_type('CV Templates Post_tag', 'cv-templates');
}
add_action('init', 'add_tags_categories');
----------------------------------------------------------------------------------
Create custom post
<?php
add_action('init', 'portfolio_register');
function portfolio_register() {
$labels = array(
'name' => _x('My Portfolio', 'post type general name'),
'singular_name' => _x('Portfolio Item', 'post type singular name'),
'add_new' => _x('Add New', 'portfolio item'),
'add_new_item' => __('Add New Portfolio Item'),
'edit_item' => __('Edit Portfolio Item'),
'new_item' => __('New Portfolio Item'),
'view_item' => __('View Portfolio Item'),
'search_items' => __('Search Portfolio'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/images/icon-admin-menu.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail')
);
register_post_type( 'portfolio' , $args );
}
register_taxonomy("Skills", array("portfolio"), array("hierarchical" => true, "label" => "Skills", "singular_label" => "Skill", "rewrite" => true));
add_action("admin_init", "admin_init");
function admin_init(){
add_meta_box("year_completed-meta", "Year Completed", "year_completed", "portfolio", "side", "low");
add_meta_box("credits_meta", "Design & Build Credits", "credits_meta", "portfolio", "normal", "low");
}
function year_completed(){
global $post;
$custom = get_post_custom($post->ID);
$year_completed = $custom["year_completed"][0];
?>
<label>Year:</label>
<input name="year_completed" value="<?php echo $year_completed; ?>" />
<?php
}
function credits_meta() {
global $post;
$custom = get_post_custom($post->ID);
$designers = $custom["designers"][0];
$developers = $custom["developers"][0];
$producers = $custom["producers"][0];
?>
<p><label>Designed By:</label><br />
<textarea cols="50" rows="5" name="designers"><?php echo $designers; ?></textarea></p>
<p><label>Built By:</label><br />
<textarea cols="50" rows="5" name="developers"><?php echo $developers; ?></textarea></p>
<p><label>Produced By:</label><br />
<textarea cols="50" rows="5" name="producers"><?php echo $producers; ?></textarea></p>
<?php
}
add_meta_box( $id, $title, $callback, $page, $context, $priority );
global $post;
$custom = get_post_custom($post->ID);
add_action('save_post', 'save_details');
function save_details(){
global $post;
update_post_meta($post->ID, "year_completed", $_POST["year_completed"]);
update_post_meta($post->ID, "designers", $_POST["designers"]);
update_post_meta($post->ID, "developers", $_POST["developers"]);
update_post_meta($post->ID, "producers", $_POST["producers"]);
}
add_action("manage_posts_custom_column", "portfolio_custom_columns");
add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
function portfolio_edit_columns($columns){
$columns = array(
"cb" => "<input type='checkbox' />",
"title" => "Portfolio Title",
"description" => "Description",
"year" => "Year Completed",
"skills" => "Skills",
);
return $columns;
}
function portfolio_custom_columns($column){
global $post;
switch ($column) {
case "description":
the_excerpt();
break;
case "year":
$custom = get_post_custom();
echo $custom["year_completed"][0];
break;
case "skills":
echo get_the_term_list($post->ID, 'Skills', '', ', ','');
break;
}
}
?>
Comments
Post a Comment