<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, ...
Plugin:http://wordpress.org/plugins/custom-post-type-cpt-cusom-taxonomy-ct-manager/
Wordpress Add Recipe Custom Menu
Ad following code Function.php file
register_post_type( 'recipes', array(
'labels' => array(
'name' => 'Recipe',
'singular_name' => 'Recipe',
'add_new' => 'Add New',
'add_new_item' => 'Add New Recipe',
'edit_item' => 'Edit Recipe',
'edit' => 'Edit',
'new_item' => 'New Recipe',
'view_item' => 'View Recipe',
'search_items' => 'Search Recipes',
'not_found' => 'No recipes found',
'not_found_in_trash' => 'No recipes found in Trash',
'view' => 'View Recipe'
),
'public' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'query_var' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'custom-fields', 'comments' ),
'taxonomies' => array('category','post_tag')
)
);
register_taxonomy(
'recipes_category',
'recipes',
array(
'hierarchical' => true,
'label' => 'Categories',
'public' => true,
'query_var' => true,
'show_tagcloud' => true,
'rewrite' => Array(
'slug' => 'recipes_category')
)
);
function add_new_columns($defaults) {
$defaults['recipes_cats'] = __('Categories');
return $defaults;
}
function add_column_data( $column_name, $post_id ) {
if( $column_name == 'recipes_cats' ) {
$_posttype = 'recipes';
$_taxonomy = 'recipes_category';
$terms = get_the_terms( $post_id, $_taxonomy );
if ( !empty( $terms ) ) {
$out = array();
foreach ( $terms as $c )
$_taxonomy_title = esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display'));
$out[] = "<a href='edit.php?recipes_category=$_taxonomy_title&post_type=$_posttype'>$_taxonomy_title</a>";
echo join( ', ', $out );
}
else {
_e('Uncategorized');
}
}
}
add_filter( 'manage_recipes_posts_columns', 'add_new_columns' );
add_action( 'manage_posts_custom_column', 'add_column_data', 10, 2 );
--------------------------------------------------------
add_action('init', 'menus_register');
function menus_register() {
$labels = array(
'name' => _x('Recipes', 'post type general name'),
'singular_name' => _x('Recipes Item', 'post type singular name'),
'add_new' => _x('Add New Recipes', 'recipes item'),
'add_new_item' => __('Add New Recipes Item'),
'edit_item' => __('Edit Recipes Item'),
'new_item' => __('New Recipes Item'),
'view_item' => __('View Recipes Item'),
'search_items' => __('Search Recipes'),
'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','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',)
);
register_post_type( 'menus' , $args );
}
register_taxonomy("Categories", array("menus"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Categories", "rewrite" => true));
add_action("admin_init", "admin_init");
function admin_init(){
add_meta_box( "Design","Build Credits","menus", "normal", "low");
}
global $post;
$custom = get_post_custom($post->ID);
add_action("manage_posts_custom_column", "menus_custom_columns");
add_filter("manage_edit-menus_columns", "menus_edit_columns");
function menus_edit_columns($columns){
$columns = array(
"cb" => "<input type='checkbox' />",
"title" => "Recipes Title",
"description" => "Description",
"featured_image" => "Image",
"cat" => "Categories",
"author" => "Author",
"date" => "Date",
);
return $columns;
}
function menus_custom_columns($column){
global $post;
switch ($column) {
case "description":
//the_excerpt();
echo substr(get_the_excerpt(), 0,50);
break;
case "cat":
echo get_the_term_list($post->ID, 'Categories', '', ', ','');
break;
}
}
//feature image
add_theme_support('post-thumbnails');
add_image_size('featured_preview', 55, 55, true);
// GET FEATURED IMAGE
function ST4_get_featured_image($post_ID) {
$post_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
return $post_thumbnail_img[0];
}
}
// ADD NEW COLUMN
function ST4_columns_head($defaults) {
$defaults['featured_image'] = 'Featured Image';
return $defaults;
}
// SHOW THE FEATURED IMAGE
function ST4_columns_content($column_name, $post_ID) {
if ($column_name == 'featured_image') {
$post_featured_image = ST4_get_featured_image($post_ID);
if ($post_featured_image) {
echo '<img src="' . $post_featured_image . '" width=75px />';
}
}
}
add_filter('manage_posts_columns', 'ST4_columns_head');
add_action('manage_posts_custom_column', 'ST4_columns_content', 10, 2);
Comments
Post a Comment