Skip to content

Instantly share code, notes, and snippets.

View jeffikus's full-sized avatar
💻
Themes at Automattic.com

Jeffrey Pearce jeffikus

💻
Themes at Automattic.com
View GitHub Profile
<li id="slide-5261" class="slide slide-number-1 flex-active-slide" style="width: 100%; float: left; margin-right: -100%; position: relative; opacity: 1; display: block; z-index: 2;">
<section class="entry col-full">
<p>This is a custom post type slide.&nbsp;Aliquam erat volutpat. Vivamus eget mi velit, sed convallis tellus. Suspendisse sit amet lacinia nisl. Nam tempus mi sed odio fringilla bibendum. Vivamus nisl ipsum, imperdiet eu euismod a, tincidunt aliquam leo. Praesent dolor est, dignissim id placerat id, cursus id diam.</p>
</section>
</li>
@jeffikus
jeffikus / functions.php
Last active December 10, 2015 11:03
IDX fix
<?php
add_filter( 'woo_template_parts', 'idx_search_fix', 1 );
function idx_search_fix( $templates ) {
$options = get_option('fmc_settings');
$page_id = absint( $options['destlink'] );
if ( is_page( $page_id ) && isset( $templates[2] ) ) {
unset($templates[2]);
$templates = array_values($templates);
}
return $templates;
@jeffikus
jeffikus / functions.php
Created December 1, 2015 13:24
Modifies Projects post type to be Services
<?php
add_filter( 'projects_post_type_rewrite', 'change_projects_nomenclature_rewrite' );
add_filter( 'projects_post_type_labels', 'change_projects_nomenclature_labels' );
add_filter( 'projects_post_type_singular_name', 'change_projects_nomenclature_singular_name' );
add_filter( 'projects_post_type_plural_name', 'change_projects_nomenclature_plural_name' );
add_filter( 'projects_post_type_designation', 'change_projects_nomenclature_designation' );
function change_projects_nomenclature_rewrite() {
return array( 'slug' => 'service', 'with_front' => true );
}
@jeffikus
jeffikus / post_categories.php
Last active September 21, 2015 11:10
Get all categories from an array of posts
<?php
function get_posts_categories_optimized( $number_posts = 1000, $category_terms = array() ) {
$post_id_array = get_posts(array(
'numberposts' => $number_posts,
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => $category_terms
),
@jeffikus
jeffikus / example.js
Created September 8, 2015 21:41
Ajax Call to WP-API
jQuery( function( $ ) {
$.ajax( {
url: 'http://wcct.dev/wp-json/wp/v2/posts?filter[order]=ASC&filter[category_name]=slides&filter[posts_per_page]=-1',
success: function ( data ) {
$.each( data, function( key, value ) {
urlstring = '';
if ( value.featured_image_thumbnail_url !== null ) {
urlstring = ' data-background="' + value.featured_image_thumbnail_url + '"';
}

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

<?php
/**
* I am adding this within a loop
**/
$current_user = wp_get_current_user();
// This is data that we get from the users profile, its auto-populated based on three fields.
$user_filter_criteria = get_field('user_filter_criteria', 'user_'. $current_user->ID);
@jeffikus
jeffikus / gist:ac62f41aecfdadf362b4
Created February 5, 2015 09:28
Multi Flexslider loader by class "myslider"
<script type="text/javascript" charset="utf-8">
$(window).load(function() {
$('.myslider').each( function() {
$(this).flexslider({
directionNav: false,
smoothHeight: true
});
});
});
</script>
@jeffikus
jeffikus / woo.js
Last active August 29, 2015 14:10 — forked from DanielSantoro/woo.js
/*
* jQuery v1.9.1 included. Go allllll the way down
*/
$(document).ready(function() {
// Removes first 3 chars from Topics list - By Jeff Pearce
function setCharAt(str,index,chr) {
if(index > str.length-1) return str;
return str.substr(0,index) + chr + str.substr(index+1);
<?php
$wpdb->prepare( "SELECT post_title FROM $wpdb->posts WHERE ID = %d ", $ID );
$wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s ", 420, 'Europe' );
?>