Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Filter the aspect ratio by field idea
* @param $ratio Default ratio
* @param $id The field ID in the form, pewc_group_1234_5678
* @param $field The field object
*/
function prefix_aspect_ratio( $ratio, $id, $field ) {
// Check for our field ID here
@danjjohnson
danjjohnson / gist:549c40711c4ec074692222e0a2f182c9
Created May 11, 2017 07:18
Sensei Enfold theme integration - May 2017
global $woothemes_sensei;
global $avia_config;
remove_action( 'sensei_before_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper' ), 10 );
remove_action( 'sensei_after_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper_end' ), 10 );
add_action('sensei_before_main_content', 'my_theme_wrapper_start', 10);
add_action('sensei_after_main_content', 'my_theme_wrapper_end', 10);
function my_theme_wrapper_start() {
@pbearne
pbearne / gist:7221162
Created October 29, 2013 19:38
how to add a tax_query to pre_get_posts in wordpress
add_action( 'pre_get_posts', array( $this,'function_pre_get_posts' ) );
function function_pre_get_posts(){
// you can't use the query->set here for tax_query
// as tax query has already been made
// so you need to need add youself to any
// existing tax query
$tax_query = array(
'taxonomy' => 'tax_name',
@bueltge
bueltge / gist:6104254
Created July 29, 2013 13:21
A Look at the WordPress HTTP API: A Practical Example of wp_remote_get
<?php
/**
* Plugin Name: Twitter Demo
* Plugin URI: http://wp.tutsplus.com/tutorials/creative-coding/a-look-at-the-wordpress-http-api-a-practical-example-of-wp_remote_get/
* Description: Retrieves the number of followers and latest Tweet from your Twitter account.
* Version: 1.0.0
* Author: Tom McFarlin
* Author URI: http://tommcfarlin.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@freekrai
freekrai / multisite_functions.php
Created July 19, 2011 14:20
Some handy wordpress multisite functions
<?php
$posts = multisite_latest_post( array(
"how_many"=>10,
"how_long_days"=>30,
"how_many_words"=>50,
"more_text"=>"[...]",
"remove_html"=>true,
"sort_by"=>"post_date",
// if paginating:
"paginate"=>true,