Skip to content

Instantly share code, notes, and snippets.

View jo-snips's full-sized avatar

Jonah West jo-snips

View GitHub Profile
// Customize Events Community Datepicker
if($("div.tribe-community-events-date input.datepicker").length) {
var datepickerOpts = {
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true,
onSelect: function(selectedDate) {
var option = this.id == "EventStartDate" ? "minDate" : "maxDate";
var instance = $(this).data("datepicker");
var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
@jo-snips
jo-snips / exclude-events-by-cat.php
Last active June 5, 2023 01:02
The Events Calendar - Exclude Events by Category (pre_get_posts)
<?php
add_action( 'pre_get_posts', 'exclude_events_category' );
function exclude_events_category( $query ) {
if ( tribe_is_event() && !tribe_is_day() && !is_single() && !is_tax() && !tribe_is_month() ) {
$query->set( 'tax_query', array(
array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'slug',
'terms' => array('zoo'),
@jo-snips
jo-snips / custom-events-wp_query.php
Last active January 5, 2023 17:24
The Events Calendar - Custom Query Using WP_Query
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>array(TribeEvents::POSTTYPE),
'posts_per_page'=>10,
//order by startdate from newest to oldest
'meta_key'=>'_EventStartDate',
'orderby'=>'_EventStartDate',
'order'=>'DESC',
@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-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 / 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'] ) ) {
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@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';
@sapegin
sapegin / footer.php
Created August 7, 2012 19:10
RequireJS in Wordpress theme
@kovshenin
kovshenin / something.php
Created July 10, 2012 07:17
Yes, you can use printf and sprintf in WordPress too!
<?php
// Dirty, easy to miss a ' or " or .
echo '<a href="' . get_permalink() . '" class="link">' . get_the_title() . '</a>';
// Clean, easier to read
printf( '<a href="%s" class="link">%s</a>', get_permalink(), get_the_title() );
// Almost as clean, and more secure, maybe a little paranoic :)
printf( '<a href="%s" class="link">%s</a>', esc_url( get_permalink() ), esc_html( get_the_title() ) );