Skip to content

Instantly share code, notes, and snippets.

@billerickson
billerickson / functions.php
Last active January 21, 2021 01:17
Use the built-in post counter
<?php
/**
* Use the built-in post counter
*
* Sometimes you'll want to keep track of which post you're on in a loop.
* Some people create their own $loop_counter (ex: Genesis, https://gist.github.com/4675237 ).
* There's a better way! A loop counter is built into $wp_query. Ex:
*
* global $wp_query;
* echo $wp_query->current_post
@zackn9ne
zackn9ne / gist:3344158
Created August 13, 2012 21:13
WordPress if is Default Template
(is_page() && !is_page_template())
@jo-snips
jo-snips / events-conditional-wrappers.php
Last active March 13, 2025 17:33
The Events Calendar: Basic Conditional Wrappers
<?php
/*-----------------------------------------------------------------------------------*/
/* Conditional Logic to Detect Various Event Related Views/Pages
/*-----------------------------------------------------------------------------------*/
if( tribe_is_month() && !is_tax() ) { // Month View Page
echo 'were on the month view page';
} elseif( tribe_is_month() && is_tax() ) { // Month View Category Page
@ijy
ijy / Compass px to em
Created December 7, 2011 08:18
A Compass function to convert pixel font-sizes to em's
@function em($target, $context: $base-font-size) {
@if $target == 0 { @return 0 }
@return $target / $context + 0em;
}
$base-font-size: 15px;
h1 {
font-size: em(21px, 15px); // Outputs 1.4em
}