Skip to content

Instantly share code, notes, and snippets.

View jo-snips's full-sized avatar

Jonah West jo-snips

View GitHub Profile
@jo-snips
jo-snips / custom-wp-query-events.php
Created November 6, 2012 15:49
The Events Calendar: Get Events by Event Category w/WP_Query
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>array(TribeEvents::POSTTYPE),
'posts_per_page'=>100,
'tax_query' => array(
array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'slug',
@jo-snips
jo-snips / get_organizers.php
Created October 10, 2012 12:46
The Events Calendar: Get Organizers
<ul>
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>'tribe_organizer',
'posts_per_page'=>-1
);
$get_posts = null;
$get_posts = new WP_Query();
@jo-snips
jo-snips / filter-ical-event-item.php
Created October 8, 2012 18:22
The Events Calendar: Filter iCal Event Item
function filter_ical_description($item, $eventPost) {
$description = preg_replace( "/[\n\t\r]/", ' ', strip_tags( strip_shortcodes( $eventPost->post_content ) ) );
$item[] = 'DESCRIPTION:' . str_replace( ',','\,', $description );
return $item;
}
add_filter('tribe_ical_feed_item','filter_ical_description', 10, 2);
@jo-snips
jo-snips / truncate.php
Created October 3, 2012 18:11
Truncate Function For Excerpts
/*-------------------------------------------------------------------------------
Truncate Function For Excerpts
-------------------------------------------------------------------------------*/
function trunc($phrase, $max_words) {
$phrase_array = explode(' ',$phrase);
if(count($phrase_array) > $max_words && $max_words > 0) {
$phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).' … ';
}
return $phrase;
}
@jo-snips
jo-snips / filter-google-params.php
Created September 27, 2012 02:54
The Events Calendar: Filter Google Calendar Params
function filter_google_cal_params($params) {
global $post;
$event_details = substr( strip_shortcodes(get_the_content()), 0, 996 ) . '...';
$params = array(
'action' => 'TEMPLATE',
'text' => str_replace( ' ', '+', strip_tags( urlencode( $post->post_title ) ) ),
'dates' => $dates,
'details' => str_replace( ' ', '+', strip_tags( apply_filters( 'the_content', urlencode( $event_details ) ) ) ),
'location' => str_replace( ' ', '+', urlencode( $location ) ),
'sprop' => get_option( 'blogname' ),
@jo-snips
jo-snips / limit-recurring.php
Created September 20, 2012 21:17
The Events Calendar: Limit Recurring Event List
<?php
$upcoming = new WP_Query();
$upcoming->query( array(
'post_type' => 'tribe_events',
'eventDisplay' => 'upcoming',
'posts_per_page' => 10,
) );
$postids = Array();
if ($upcoming->have_posts()) :
while ($upcoming->have_posts()) :
@jo-snips
jo-snips / random-event-widget.php
Created September 18, 2012 15:14
The Events Calendar: Random Event Widget
<?php
/*-----------------------------------------------------------------------------------*/
/* Random Event Widget
/*-----------------------------------------------------------------------------------*/
add_action( 'widgets_init', create_function( '', "register_widget( 'Random_Event_Widget' );" ) );
class Random_Event_Widget extends WP_Widget {
@jo-snips
jo-snips / custom-wp-seo-titles.php
Last active October 10, 2015 15:18
The Events Calendar: Custom Titles w/WP SEO
<?php
add_filter('wpseo_title','my_custom_titles');
function my_custom_titles($title) {
if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
return 'Events Calendar';
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
return 'Events Calendar' . ' &raquo; ' . single_term_title('', false);
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
return 'Events List';
@jo-snips
jo-snips / custom-one-month.php
Created September 9, 2012 23:04
The Events Calendar: Custom Query for 1 Month Future Events
<?php
global $post;
$current_date = date('j M Y');
$end_date = date('j M Y', strtotime('1 month'));
echo 'Start Date:'. $current_date;
echo 'End Date:'. $end_date;
$all_events = tribe_get_events(
array(
@jo-snips
jo-snips / admin-order.php
Created August 30, 2012 22:21
The Events Calendar: Custom Event Order in Admin
<?php
/*-----------------------------------------------------------------------------------*/
/* Modify Event List Order in Admin
/*-----------------------------------------------------------------------------------*/
function set_custom_post_types_admin_order($wp_query) {
if (is_admin()) {
// Get the post type from the query
$post_type = $wp_query->query['post_type'];
if ( $post_type == 'tribe_events') {