Skip to content

Instantly share code, notes, and snippets.

@halfempty
halfempty / functions.php
Last active August 29, 2015 14:05
Gravity Forms populate
<?php
function populate_checkbox($form) {
if ( $form['id'] != 15 ) :
return $form;
endif;
foreach($form['fields'] as &$field) :
@halfempty
halfempty / exhibitions-current.php
Last active August 29, 2015 14:03
MCA Current Exhibitions example
<?php
global $post;
$args = array(
'post_type' => 'mca_exhibitions',
'posts_per_page' => -1
);
$myposts = get_posts( $args );
@halfempty
halfempty / showalltags.php
Created June 10, 2014 01:55
showalltags with count
<?php
function showalltags() {
$tags = get_tags();
$html;
foreach ($tags as $tag){
$tag_link = get_tag_link($tag->term_id);
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug} count{$tag->count}'>";
@halfempty
halfempty / instafeed.js
Created June 7, 2014 00:52
Instafeed example for @jerb0x
var feed = new Instafeed({
get: 'user',
userId: 636337139,
accessToken: '262351.467ede5.176ab1984b1d47e6b8dea518109d7a5e',
link: 'true',
clientId: '80aeda87e8c44281b83ce6f542a30933',
limit: '1',
sortBy: 'most-recent',
resolution: 'standard_resolution',
links: false,
@halfempty
halfempty / eventfunctions.php
Last active August 29, 2015 14:01
Non-AJAX Previous Events / Next Events Links for WP Events Calendar Pro
function spellerberg_get_next_events_link() {
global $wp_query;
$nextlink = '';
$paged = get_query_var( 'paged' );
if ( tribe_is_past() ) :
if ( $paged > 2 ) :
$nextpagenumber = $paged - 1;
Dear Educator,
We look forward to your visit to the MCA! Please read this email thoroughly as it holds details for your upcoming tour:
<ul>
<li><strong>Date and Time:</strong> {Creation Lab time slots, January:45}{Creation Lab time slots, February:42}{Creation Lab time slots, March:47}{Creation Lab time slots, April:50}{Creation Lab time slots, May:48}{Artist Led Tour time slots, January:43}{Artist Led Tour time slots, February:41}{Artist Led Tour time slots, March:49}{Artist Led Tour time slots, April:44}{Artist Led Tour time slots, May:46}{Off the Beaten Path time slots:51}</li>
<li><strong>Tour Type:</strong> {Tour Type:2}</li>
<li><strong>School Name:</strong> {School:21}</li>
<li><strong>Number of Students:</strong> {Number of Students:38}</li>
</ul>
<h3>TRANSPORTATION</h3>
@halfempty
halfempty / functions.php
Created June 18, 2013 19:10
Show and save data to WordPress user profiles
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
@halfempty
halfempty / functions.php
Last active December 17, 2015 12:19
WordPress Tag Search using jQuery. Demo and tutorial here: http://martyspellerberg.com/2011/11/creating-a-wordpress-tag-search-using-jquery/
<?php
function showalltags() {
$tags = get_tags();
$html;
foreach ($tags as $tag){
$tag_link = get_tag_link($tag->term_id);
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
var file_frame;
// "mca_tray_button" is the ID of my button that opens the Media window
jQuery('#mca_tray_button').live('click', function( event ){
event.preventDefault();
if ( file_frame ) {
file_frame.open();
return;
@halfempty
halfempty / is_category_or_subcategory.php
Created October 8, 2012 19:41
WordPress Is Category or Subcategory
function is_category_or_subcategory($targetcategory) {
if ( is_category() ) :
// echo '<p>the target slug is: '. $targetcategory . '.</p>';
$targetid = get_category_by_slug($targetcategory);
// echo '<p>the target id is: '. $targetid->term_id . '.</p>';
$targetid = strval($targetid->term_id);