Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
$is_ms = '';
if ( is_multisite() ) $is_ms = 'network/';
if ( $_SERVER['PHP_SELF'] === '/wp-admin/' . $is_ms . 'plugin-editor.php' ||
$_SERVER['PHP_SELF'] === '/wp-admin/' . $is_ms . 'theme-editor.php' ||
$_SERVER['PHP_SELF'] === '/wp-admin/admin-ajax.php' ){
add_action( 'init', create_function( '', 'new WPide();' ) );
}
@DrewAPicture
DrewAPicture / WP_Query Parameters
Created March 13, 2012 03:13 — 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(
We couldn’t find that file to show.
We couldn’t find that file to show.
<?php
$args = array(
'posts_per_page' => 5,
'order' => 'ASC',
'orderby' => 'title',
'meta_query' => array(
array(
'key' => '',
'value' => '',
@DrewAPicture
DrewAPicture / gist:2243601
Last active October 2, 2015 12:28
WordPress responsive captions
<?php
function dap_responsive_img_caption_filter( $val, $attr, $content = null ) {
extract( shortcode_atts( array(
'id' => '',
'align' => '',
'width' => '',
'caption' => ''
), $attr
) );
@DrewAPicture
DrewAPicture / subfolder_post_formats
Created April 2, 2012 20:51
Post Formats templates in sub-folder
<?php $format = get_post_format();
if ( $format === false )
$format = 'standard';
get_template_part( 'formats/content', $format ); ?>
@DrewAPicture
DrewAPicture / gist:2896578
Created June 8, 2012 16:18
Display unfiltered events content on single
if ( is_single() && in_category( 'recent-events' ) ) {
$content = get_the_content();
echo $content;
} else {
// Main loop content goes here
}
@DrewAPicture
DrewAPicture / gist:2906793
Created June 10, 2012 18:11
Link to SmugMug gallery from Events Archive + SmugMug thumb as link
<?php if ( $recent->have_posts() ) : while ( $recent->have_posts() ) : $recent->the_post();
// Pull the URL from the_content()
$link = esc_url( get_the_content() );
// Check if it's a properly formed URL, append http:// if not. Don't want user to struggle here
if ( ! preg_match('/^http:\/\//', $link ) )
$link = 'http://' . $link;
// Setup args for our oEmbed
@DrewAPicture
DrewAPicture / gist:2928548
Created June 14, 2012 07:00
Verbose or compact?
<?php
if ( ! wp_is_large_network( 'users' ) ) {
$num = '<a href="' . network_admin_url('users.php') . '">' . $num . '</a>';
$text = '<a href="' . network_admin_url('users.php') . '">' . $text . '</a>';
} else {
$num = '<a href="' . network_admin_url('users.php') . '">10,000+</a>';
$text = '<a href="' . network_admin_url('users.php') . '">' . $text . '</a>';
?>