Skip to content

Instantly share code, notes, and snippets.

@stompweb
stompweb / filter-events.php
Created June 29, 2012 14:27
Filter events pre_get_posts
// Function to display only upcoming events for Sugar Events Calendar on the main Events archive.
function sc_filter_events( $query ) {
if( is_post_type_archive('sc_event') && (!is_admin()) && ($query->is_main_query()) ) {
$meta = array(
array(
'key' => 'sc_event_date_time',
'value' => time(),
@pdewouters
pdewouters / gist:2995754
Created June 26, 2012 13:21
change post order on post type archive / taxonomy archive
add_action( 'pre_get_posts', 'child_sort_post_order' );
function child_sort_post_order( $query ) {
if ( is_post_type_archive('my_post_type') || is_tax() ){
$query->query_vars['orderby'] = 'title';
$query->query_vars['order'] = 'asc';
return;
@pdewouters
pdewouters / gist:2973255
Created June 22, 2012 14:55
typography framework
/*
http://csswizardry.com/2012/02/pragmatic-practical-font-sizing-in-css/
Housekeeping */
*{ margin:0; padding:0; }
/* Define your base font-size here; most elements will inherit this. */
html{
font-size:1em; /* Assuming 16px... */
line-height:1.5; /* 24px (This is now our magic number; all subsequent margin-bottoms and line-heights want to be a multiple of this number in order to maintain vertical rhythm.) */
}
@pdewouters
pdewouters / gist:2972729
Created June 22, 2012 13:27
smooth web fonts
/* ==================================================================================
                        THE TRICK
Add text-shadow on the top-left and the bottom-right to smooth text
=================================================================================== */
 
 
h1.title { /*  It works very well with Windows XP (standard / cleartype method) */
    text-shadow:-1px -1px 1px rgba(255,255,255,0.2), /* top-left */
    1px 1px 1px rgba(255,255,255,0.2), /* bottom-right */
    1px 1px 1px rgba(0,0,0,0.7); /* shadow */
@pdewouters
pdewouters / gist:2972669
Created June 22, 2012 13:12
CSS diagnostics
/* http://css-tricks.com/snippets/css/css-diagnostics/ */
/* Empty Elements */
div:empty, span:empty, li:empty, p:empty, td:empty, th:empty
{ padding: 20px; border: 5px dotted yellow !important; }
/* Empty Attributes */
*[alt=""], *[title=""], *[class=""], *[id=""], a[href=""], a[href="#"]
{ border: 5px solid yellow !important; }
/* Deprecated Elements */
@Abban
Abban / WordPress Theme Customizer Sample.php
Created June 21, 2012 21:09
WordPress Theme Customizer Sample
<?php
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120,
));
// =============================
@pdewouters
pdewouters / gist:2870358
Created June 4, 2012 19:34
dropdown select for WordPress custom menu
// Place the action in your theme setup function
add_action('genesis_after_header','secundo_mobile_menu_primary');
// generates a dropdown select element for navigation on mobile devices
function secundo_mobile_menu_primary(){
wp_nav_menu(
array(
'menu' => 'Primary Navigation', // your theme location here
'walker' => new Walker_Nav_Menu_Mobile(),
@wpsmith
wpsmith / taxonomies.php
Created May 30, 2012 17:25
Registering Multiple Taxonomies
<?php
/**
* Taxonomies
*
* This file registers any custom taxonomies
*
* @package WPS_Starter_Genesis_Child
* @author Travis Smith <travis@wpsmith.net>
* @copyright Copyright (c) 2012, Travis Smith
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
<?php
/*
* JSON list of tweets using:
* http://dev.twitter.com/doc/get/statuses/user_timeline
* Cached using WP transient API.
* http://www.problogdesign.com/wordpress/add-a-backup-to-embedded-tweets-in-wordpress/
*/
// Configuration.
$numTweets = 3;
@pdewouters
pdewouters / gist:2757855
Created May 20, 2012 12:12
Add parent class to menu items that have a sub menu
// http://codex.wordpress.org/Function_Reference/wp_nav_menu#How_to_add_a_parent_class_for_menu_item
add_filter('wp_nav_menu_objects', function ($items) {
$hasSub = function ($menu_item_id, &$items) {
foreach ($items as $item) {
if ($item->menu_item_parent && $item->menu_item_parent==$menu_item_id) {
return true;
}
}
return false;
};