Skip to content

Instantly share code, notes, and snippets.

View jo-snips's full-sized avatar

Jonah West jo-snips

View GitHub Profile
<?php
// Add this to your functions.php file to create a venue query that queries venues in order of number of events.
// You may need to add a limit statement if you want more events to be returned than the default for the query.
add_filter( 'pre_get_posts', 'my_function_to_get_venues_by_event_numbers', 10, 1 );
function my_function_to_get_venues_by_event_numbers( $query ) {
if ( $query->tribe_is_event_venue && !is_single() ) {
$query = new WP_Query();
$tribe_query = new TribeEventsQuery();
$query->query_vars['post_type'] = TribeEvents::VENUE_POST_TYPE;
add_filter( 'posts_fields', 'my_posts_fields_for_venues_function', 20, 1 );
@jo-snips
jo-snips / order-events-in-admin.php
Created March 5, 2013 04:47
The Events Calendar - Order Events In Admin By Start Date
<?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'];
@jo-snips
jo-snips / get-single-months-events.php
Last active December 14, 2015 08:28
The Events Calendar - Get Single Months Events
<h1>January 2013</h1>
<?php
global $post;
$current_date = '2013-01-01';
$end_date = '2013-01-31';
echo '<p>Start Date: ' . $current_date . '</p>';
echo '<p>End Date: ' . $end_date . '</p>';
$get_posts = tribe_get_events(array('start_date'=>$current_date,'end_date'=>$end_date,'posts_per_page'=>10) );
@jo-snips
jo-snips / custom-venue-query.php
Created February 18, 2013 15:24
The Events Calendar - Custom Venue Query
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>'tribe_venue',
'posts_per_page'=>-1
);
$get_posts = null;
$get_posts = new WP_Query();
@jo-snips
jo-snips / organizer-list.php
Created January 22, 2013 20:36
The Events Calendar - Display Organizers
<ul>
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>'tribe_organizer',
'posts_per_page'=>-1,
'order'=>'ASC',
'orderby'=>'title'
);
@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 / style-calendar-days.txt
Created January 14, 2013 03:30
The Events Calendar - Link to thread describing how to style calendar days in the mini calendar.
http://tri.be/support/forums/topic/calendar-widget-4/
@jo-snips
jo-snips / custom-event-title-variable.php
Created January 10, 2013 21:10
This is a variation of custom event titles where the page title is defined by a variable.
if(isset($pagecustoms['zeitgeist_header_title'])) {
$htitle = $pagecustoms['zeitgeist_header_title'];
} elseif( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
$htitle = 'Events Calendar';
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
$htitle = 'Events Calendar: ' . tribe_meta_event_category_name();
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
$htitle = 'Events List';
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() && is_tax() ) { // Category Events List
$htitle = 'Events List: ' . tribe_meta_event_category_name();
@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 / include-private-events.php
Created January 3, 2013 15:48
The Events Calendar - Include Private Events in Calendar
add_action( 'pre_get_posts', 'include_private_events' );
function include_private_events( $query ) {
if ( $query->query_vars['post_type'] == TribeEvents::POSTTYPE && $query->query_vars['eventDisplay'] == 'month' && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_status',
array(
'publish',
'private'
)
);