Skip to content

Instantly share code, notes, and snippets.

@eddiemoya
eddiemoya / wp-config.php
Created July 2, 2012 21:19
WordPress - wp-config.php settings for dynamic host detection.
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content' );
define( 'WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins' );
define( 'PLUGINDIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins' );
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content');
define( 'WP_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content/plugins');
define( 'UPLOADS', 'wp-content/uploads' );
@eddiemoya
eddiemoya / return-template-part.php
Created July 2, 2012 23:06
Return Template Part - WordPress
function return_template_part($template, $specialized_name = ''){
ob_start();
get_template_part($template, $specialized_name);
return ob_get_clean();
}
@eddiemoya
eddiemoya / user-by-taxrole.sql
Created September 7, 2012 21:16
Get users by role with taxonomy sql
SELECT DISTINCT
u.ID,
u.user_login,
u.user_nicename,
u.user_email,
u.display_name,
m2.meta_value as role,
GROUP_CONCAT(DISTINCT m.meta_value) AS terms
FROM wp_users as u
LEFT JOIN wp_usermeta AS m
@eddiemoya
eddiemoya / get_users_by_role_tax_intersection.php
Created September 7, 2012 23:17
Query building function for getting users by role and taxonomy
function get_user_role_tax_intersection($args = array()){
global $wpdb;
$default_args = array(
'hide_untaxed' => true
'terms' => array(),
'roles' => array('administrator')
);
$args = array_merge($default_args, $args);
<!-- OLD -->
<article class="widget content-container span12 image-widget">
<header class="content-header">
<h3>Discover ideas. Ask Questions. Be you. Welcome to the Community.</h3>
</header>
<article class="content-container">
<img src="">
</article>
</article>
@eddiemoya
eddiemoya / resultslist-archive.php
Created September 14, 2012 20:52
resultslist archive.php
<?php
if(!is_ajax()) {
get_template_part('parts/header', 'results-list');
}
$post_type = get_query_var('post_type');
$post_type = (is_array($post_type)) ? $post_type[0] : $post_type;
loop('results-list', array($post_type, 'post'), 'parts', 'parts/no-results.php');
@eddiemoya
eddiemoya / git-move.sh
Last active October 10, 2015 17:28
Git Move (Stash Save, Checkout, Stash Apply in one command)
move = !git stash && git checkout $1 && git stash apply stash@{0} && wait
@eddiemoya
eddiemoya / custom-post-type.php
Created September 17, 2012 21:04
Example Custom Post Type
public function register_video_type() {
$labels = array(
'name' => _x('Video', 'post type general name'),
'singular_name' => _x('Video', 'post type singular name'),
'add_new' => _x('Add New', 'section'),
'add_new_item' => __('Add New Video'),
'edit_item' => __('Edit Video'),
'new_item' => __('New Video'),
'all_items' => __('All Videos'),
'view_item' => __('View Video'),
@eddiemoya
eddiemoya / gist:3740873
Created September 18, 2012 02:09 — forked from tim-steele/gist:3738582
Featured Category Questions
<article class="widget content-container featured-category-questions widget span12">
<header class="content-header">
<h1>Featured Questions</h1>
</header>
<section class="content-body clearfix">
<section class="span6">
<!-- DROPZONE: FIRST FEATURED QUESTION -->
<article class="content-container featured-post span12">
<header class="content-header">
<h3>Featured Blog Post</h3>
</header>
<section class="content-body clearfix">
<div class="featured-image span6">
<img src="/wp-content/uploads/2012/07/blogmodule.jpg">
</div>