Skip to content

Instantly share code, notes, and snippets.

@billerickson
billerickson / gist:3698476
Last active February 23, 2024 16:49 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
<?php
/*
* Resize images dynamically using wp built in functions
* @author Victor Teixeira
* @link http://core.trac.wordpress.org/ticket/15311
*
* php 5.2+
*
* Exemple use:
Change line 133 FROM:
$perm = 'edit_' . ( 'page' == $post->post_type ? 'post' : $post->post_type ) . 's';
TO:
$perm = 'edit_' . ( 'page' == $post->post_type ? 'page' : 'post' ) . 's';
@billerickson
billerickson / gist:2047229
Last active July 10, 2023 22:04
Improve performance of WP_Query
<?php
$args = array(
// Normal query goes here //
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);
@billerickson
billerickson / gist:1325546
Last active February 7, 2023 14:11
Custom Avatar Field
<?php
/**
* Add Custom Avatar Field
* @author Bill Erickson
* @link http://www.billerickson.net/wordpress-custom-avatar/
*
* @param object $user
*/
function be_custom_avatar_field( $user ) { ?>
<h3>Custom Avatar</h3>
@billerickson
billerickson / gist:1325991
Created October 30, 2011 14:55
Menu With Description class
<?php
class Menu_With_Description extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
@billerickson
billerickson / gist:1267777
Created October 6, 2011 15:56
Improvements to Display Posts Shortcode
<?php
/**
* Plugin Name: Display Posts Shortcode
* Plugin URI: http://www.billerickson.net/shortcode-to-display-posts/
* Description: Display a listing of posts using the [display-posts] shortcode
* Version: 1.6
* Author: Bill Erickson
* Author URI: http://www.billerickson.net
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
@billerickson
billerickson / gist:1325474
Created October 30, 2011 04:18
Create Price Range Taxonomy
<?php
/**
* Create Price Range Taxonomy
* @author Bill Erickson
* @link http://www.billerickson.net/wordpress-custom-taxonomies/
*
*/
function be_register_price_range_taxonomy() {
@billerickson
billerickson / gist:1307387
Created October 23, 2011 13:57
Taxonomy Listing
<?php
/**
* Template Name: Taxonomy Listing
*
* @package BE Genesis Child
* @author Bill Erickson <bill@billerickson.net>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
@billerickson
billerickson / gist:1380849
Created November 20, 2011 20:33
Add Taxonomy to Page Names - CMS Page Order
<?php
/**
* Add Taxonomy to Page Names - CMS Page Order
* Taxonomy: 'rotator-location'.
* Example of result: Page Name (taxonomy term)
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/add-taxonomy-to-page-names-cms-page-order
*