Skip to content

Instantly share code, notes, and snippets.

@leogono
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leogono/3f3e71e04c2df482e7b3 to your computer and use it in GitHub Desktop.
Save leogono/3f3e71e04c2df482e7b3 to your computer and use it in GitHub Desktop.
Event Calendar month view
<?php
/**
*
* add events calendar classes to display calendar propery in homepage
*
*/
add_filter( 'body_class', 'add_class_for_calendar_view' );
function add_class_for_calendar_view( $classes )
{
if(is_front_page())
{
$classes[] = 'events-gridview';
$classes[] = 'events-archive';
}
return $classes;
}
/**
*
* enqueue events calendar scripts for homepage
*
*/
add_action('wp_enqueue_scripts', 'enqueue_style');
function enqueue_style()
{
wp_enqueue_script( 'custom', get_stylesheet_directory_uri() . '/assets/js/custom-tribe-events.js', array('jquery'), true, true );
if(is_front_page())
{
Tribe_Template_Factory::asset_package('events-css');
Tribe_Template_Factory::asset_package('calendar-script');
}
}
/**
*
* shortcode to show events calendar
*
*/
add_shortcode('show_events_calendar', 'show_events_calendar_func');
function show_events_calendar_func()
{
ob_start();
tribe_events_before_html();
tribe_show_month();
tribe_events_after_html();
$html .= ob_get_clean();
return $html;
}
/**
*
* modify events calendar title in front page
*/
add_filter('tribe_events_title', 'remove_default_calendar_title');
function remove_default_calendar_title($title)
{
if(is_front_page())
{
$title = sprintf(
__( 'Events for %s', 'tribe-events-calendar' ),
date_i18n( tribe_get_option( 'monthAndYearFormat', 'F Y' ), strtotime( tribe_get_month_view_date() ) )
);
}
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment