Skip to content

Instantly share code, notes, and snippets.

@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;
@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 / 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 / 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 / gist:6b428590eadea86c508c
Created November 7, 2014 01:34
WordPress vimeo ids to params and markup
<?php
// Curl helper function
function curl_get($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$return = curl_exec($curl);
curl_close($curl);
@halfempty
halfempty / layout.js
Created February 4, 2015 17:51
Workaround to prevent under-layer scrolling on iOS
var myScrollTop = 0;
jQuery.fn.openLightbox = function() {
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
myScrollTop = $('body').scrollTop();
var wpadminbar = 0;
if ($('#wpadminbar').length != 0) {
wpadminbar = $('#wpadminbar').outerHeight();
@halfempty
halfempty / srcset.php
Last active August 29, 2015 14:15
srcset image tag functions for WordPress
// Image Sizes
add_image_size( 'padmini', 1024 );
add_image_size( 'phone', 1136 );
add_image_size( 'phoneplus', 1334 );
add_image_size( 'padretina', 2048 );
function spellerberg_get_image($imageid,$fallbacksize = 'full') {
$sizes[] = wp_get_attachment_image_src( $imageid, 'padmini');
$sizes[] = wp_get_attachment_image_src( $imageid, 'phone');
@halfempty
halfempty / functions.php
Created May 19, 2015 05:51
WordPress Decoy Page
<?php
function decoy_page( $query ) {
global $wp;
if ( !is_admin() && $query->is_main_query() ) {
if ( ( $query->get( 'page_id' ) == get_option( 'page_on_front' ) && get_option( 'page_on_front' ) ) || empty( $wp->query_string ) ) {
echo 'This displays when set to A Static Page and the homepage is showing.';
@halfempty
halfempty / connections.php
Created September 1, 2015 00:21
Sample Posts 2 Posts + The Event Calendar connections
<?php
/*
Plugin Name: Connections
*/
function clock_p2p_register_connections() {
p2p_register_connection_type( array(
'name' => 'posts_to_tribe_events',
@halfempty
halfempty / a.html
Created September 28, 2012 02:01
Centering a Google Map on the Latest WordPress Post
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri() ?>/map.js"></script>