Skip to content

Instantly share code, notes, and snippets.

View wpspeak's full-sized avatar

WPSpeak wpspeak

View GitHub Profile
@GaryJones
GaryJones / functions.php
Created February 23, 2012 13:21
Cache bust the style.css reference in WordPress.
<?php
add_filter( 'stylesheet_uri', 'gmj_stylesheet_uri' );
/**
* Cache bust the style.css reference.
*
* Includes the file last modified time as a querystring.
*
* @author Gary Jones
* @link https://gist.github.com/1892762
@markoheijnen
markoheijnen / gist:2572299
Created May 1, 2012 23:16
Adding post type to the Recent post widget to WordPress 3.4+
<?php
add_action( 'in_widget_form', 'extend_recent_posts_form', 10, 3 );
add_filter( 'widget_update_callback', 'extend_recent_posts_update', 10, 4 );
add_filter( 'widget_title', 'extend_recent_posts_init_query_filter', 10, 3 );
add_filter( 'widget_posts_args', 'extend_recent_posts_query' );
function extend_recent_posts_form( $widget, $return, $instance ) {
if( ! is_a( $widget, 'WP_Widget_Recent_Posts' ) )
return;
@mikejolley
mikejolley / gist:3123855
Created July 16, 2012 17:18
WooCommerce - Malaysia states
/**
* Code goes in functions.php or a custom plugin.
*/
add_filter( 'woocommerce_states', 'malaysia_woocommerce_states' );
function malaysia_woocommerce_states( $states ) {
$states['MY'] = array(
'JHR' => __('Johor', 'woocommerce') ,
'KDH' => __('Kedah', 'woocommerce') ,
<?php
/**
* Grid Loop on Portfolio archive
*
* @author Bill Erickson
* @link https://github.com/billerickson/Genesis-Grid/wiki/Home
*
* @param bool $grid, whether to use grid loop
* @param object $query, the WP Query
* @return bool
@surefirewebserv
surefirewebserv / simple-social-centered.css
Last active August 31, 2023 15:51
Center Simple Social Icons when doing responsive styles
/* Align Simple Social Icons Centered */
.simple-social-icons ul.alignright,
.simple-social-icon ul.alignleft {
text-align: center;
}
.simple-social-icons ul.alignright li,
.simple-social-icons ul.alignleft li {
display: inline-block;
float: none;
@tnorthcutt
tnorthcutt / functions.php
Created May 28, 2013 01:01
Short-circuit genesis_get_option to set Genesis options for a specific situation.
<?php
// These are just two examples
// Uses anonymous functions since these are for one-time use
// Short-circuit genesis_get_option to show thumbnails
add_filter( 'genesis_pre_get_option_content_archive_thumbnail', function() {
return 1; // 1 shows thumbnails
} );
@robneu
robneu / wordpress-font-awesome-cdn.php
Last active November 29, 2022 10:47
Add Font Awesome to WordPress using a CDN
<?php
add_action( 'wp_enqueue_scripts', 'prefix_enqueue_awesome' );
/**
* Register and load font awesome CSS files using a CDN.
*
* @link http://www.bootstrapcdn.com/#fontawesome
* @author FAT Media
*/
function prefix_enqueue_awesome() {
wp_enqueue_style( 'prefix-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css', array(), '4.0.3' );
@norcross
norcross / jetpack-twitter-via.php
Created July 18, 2013 03:06
add twitter handle in Jetpack
<?php
add_filter ( 'jetpack_sharing_twitter_via', 'rkv_jp_twitter_via' );
function rkv_jp_twitter_via() {
return 'YOUR_TWITTER_NAME';
}
<?php
//* Do NOT include this comment or the opening php tag above
//* Wrap first word of widget title into a span tag
add_filter ( 'widget_title', 'b3m_add_span_widgets' );
function b3m_add_span_widgets( $old_title ) {
$title = explode( " ", $old_title, 2 );
if ( isset( $title[0] ) && isset( $title[1] ) ) {
@longjasonm
longjasonm / functions.php
Last active November 6, 2019 00:40
How to set up a 4-column footer in the Genesis framework. I've only seen code about 3-column setups, but I need 4 for a design I'm working on. Here's my code.
<?php
//* Do NOT include the opening php tag
// Add support for 4-column footer widgets
add_theme_support( 'genesis-footer-widgets', 4 );