Skip to content

Instantly share code, notes, and snippets.

View jonahcoyote's full-sized avatar

Jonah C West jonahcoyote

View GitHub Profile
@jonahcoyote
jonahcoyote / featured-image-link.php
Created March 7, 2012 18:44
Wrap post thumbnail in custom field link
@jonahcoyote
jonahcoyote / filter-by-tax.php
Created June 25, 2012 22:11
Wordpress: Admin Filter Posts by Taxonomy
<?php
function restrict_posts_by_tax() {
global $typenow;
$post_type = 'books'; // change HERE
$taxonomy = 'genre'; // change HERE
if ($typenow == $post_type) {
$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
$info_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
@jonahcoyote
jonahcoyote / events-conditional-wrappers.php
Last active October 6, 2015 12:18 — forked from ooobo/events-conditional-wrappers.php
The Events Calendar: Basic Conditional Wrappers
if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
} elseif( tribe_is_event() && is_single() ) { // Single Events
} elseif( tribe_is_day() ) { // Single Event Days
@jonahcoyote
jonahcoyote / facebook-import-set-category.php
Created February 22, 2013 18:51
The Events Calendar - Facebook Import Set Category
/**
* Sets events from Facebook by Tribe Events Facebook to use a predetermined category
*
* IMPORTANT: Replace "{CATEGORY ID}" on Line 35 (wp_set_object_terms...) with the ID of the category for imported events on your site.
* IMPORTANT: This sets a term in the default "category" taxonomy. You may prefer to set the term in the 'tribe_events_cat' taxonomy
*
* @param $post_id int id of post being inserted
* @param $post obj the post object
*
* @uses get_post_type()
@jonahcoyote
jonahcoyote / add-date-to-rss-feed.php
Last active December 14, 2015 04:49
The Events Calendar - Add Event Date to RSS Feed
<?php
// Add Tribe Event Namespace
add_filter( 'rss2_ns', 'events_rss2_namespace' );
function events_rss2_namespace() {
echo 'xmlns:ev="http://purl.org/rss/2.0/modules/event/"';
}
// Add Event Date to RSS Feeds
add_action('rss_item','tribe_rss_feed_add_eventdate');
@jonahcoyote
jonahcoyote / auto-set-meta-maps.php
Last active December 14, 2015 04:59
The Events Calendar - Auto Set Meta on Facebook Import
<?php
function tribe_enable_map_on_imported_events( $post_id ) {
// stop if args aren't set or we're not dealing with an event
if (! isset($post_id) && ! get_post_type($post_id) == 'tribe_events') {
return;
}
// get the field Tribe sets for event source
@jonahcoyote
jonahcoyote / export.sql
Last active January 8, 2019 00:05
Sabai Directory Export SQL
/*
Intro:
Here are some export examples you can use to export Sabai directory data. I'm no MySQL expert and there's probably better ways to run these queries but this worked for my purposes. I hope this helps!
Note, this is going to export all columns and you'll need to manually go in and remove columns you don't need in Excel or Numbers or whatever spreadsheet program you have.
Usage:
This is meant to be run in phpMyAdmin. Look at your own table structure and modify as necessary for any custom fields, table prefix, and custom bundle. Custom fields are storedin their own tables and cross linked via entity_id which is the id of a listing.
*/
<?php
/**
* Export WordPress post data to CSV
* Based on <http://stackoverflow.com/a/3474698> and <http://ran.ge/2009/10/27/howto-create-stream-csv-php/>
*/
/**
*********************************************************************
* Configuration
*********************************************************************
<?php
/**
* update ~line 26 to include 2 argument params as such:
*/
add_filter( 'posts_orderby', array( __CLASS__, 'events_search_orderby' ), 10, 2 );
/**
* update static function `events_search_orderby` (replace with the following method starting at ~line 159)
*/
@jonahcoyote
jonahcoyote / body-classes.php
Created February 22, 2016 17:47 — forked from jo-snips/body-classes.php
WordPress - Dynamic Browser Body Classes
/*-----------------------------------------------------------------------------------*/
/* Adds new body classes
/*-----------------------------------------------------------------------------------*/
add_filter('body_class', 'add_browser_classes');
function add_browser_classes($classes){
if(is_singular()) {
global $post;
$classes[] = $post->post_name;
}