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 / register-objects-for-post-type.php
Created March 29, 2013 14:41
Register Taxonomies For Post Types
<?php
/*-----------------------------------------------------------------------------------*/
/* Register Taxes for Post Types
/*-----------------------------------------------------------------------------------*/
function run_init() {
register_taxonomy_for_object_type('category', 'tribe_events');
register_taxonomy_for_object_type('post_tag', 'tribe_events');
register_taxonomy_for_object_type('tribe_events_cat', 'post');
@jo-snips
jo-snips / custom-events-advanced-widget.php
Created June 9, 2012 16:17
The Events Calendar: Custom Events Advanced List Widget
<?php
/**
* This is the template for the output of the events list widget.
* All the items are turned on and off through the widget admin.
* There is currently no default styling, which is highly needed.
*
* You can customize this view by putting a replacement file of the same name (events-list-load-widget-display.php) in the events/ directory of your theme.
*
* When the template is loaded, the following vars are set: $start, $end, $venue, $address, $city, $state, $province'], $zip, $country, $phone, $cost
@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') {
@jo-snips
jo-snips / custom-tribe-title.php
Last active September 5, 2018 07:30
The Events Calendar: Filter Tribe Events Title
add_filter('tribe_get_events_title','custom_get_events_title');
function custom_get_events_title( $depth=true ) {
global $wp_query;
$tribe_ecp = TribeEvents::instance();
$title = __('Class Schedule', 'tribe-events-calendar');
// TODO: Use the displayed dates for the title
/*
if ( tribe_is_upcoming() || isset( $_REQUEST['tribe-bar-date'] ) ) {
@jo-snips
jo-snips / custom-events-query.php
Created January 3, 2013 21:14
The Events Calendar - Get Events by Organizer
<?php
$args = array(
'post_type' => array(TribeEvents::POSTTYPE), // use post_type IN () to avoid old tribe queries
'posts_per_page' => -1,
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_EventOrganizerID',
'value' => get_the_ID(),
@jo-snips
jo-snips / default_to_list.php
Created June 26, 2013 02:29
The Events Calendar - Default to List View on Event Categories
<?php
/*-------------------------------------------------------*/
/* Default to List View When Viewing Event Categories
/*-------------------------------------------------------*/
add_action( 'pre_get_posts', 'default_to_list_view' );
function default_to_list_view( $query ) {
if ( is_tax(TribeEvents::TAXONOMY) && $query->query_vars['post_type'] == TribeEvents::POSTTYPE && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'eventDisplay', 'upcoming' );
@jo-snips
jo-snips / filter-custom-organizer-link.php
Created March 30, 2012 18:44
The Events Calendar: Filter tribe_get_organizer_link()
@jo-snips
jo-snips / query-post-type-with-meta.sql
Created January 17, 2013 22:57
Get posts of a certain post type only if a certain meta field is not blank and split names returned in rows into new columns.
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(wp_posts.post_title, ' ', 1), ' ', -1) as memberfirst,
SUBSTRING_INDEX(SUBSTRING_INDEX(wp_posts.post_title, ' ', 2), ' ', -1) as memberlast,
wp_postmeta.meta_value
FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
AND wp_posts.post_type = 'member'
AND wp_posts.post_status = 'publish'
AND wp_postmeta.meta_key = 'email'
AND wp_postmeta.meta_value != ''
ORDER BY wp_posts.post_date DESC
@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 / page-random-event.php
Created March 9, 2012 02:44 — forked from jkudish/page-random-event.php
The Events Calendar: This is an example of a query which gets a single random event from the 'featured' event category amongst events from The Events Calendar
<?php
/**
* This is an example of a query which gets a single random event from the
* 'featured' event category amongsts evetns from The Events Calendar
*
* @see http://tri.be/support/forums/topic/random-featured-event-custom-widget/
*/
get_header();