Skip to content

Instantly share code, notes, and snippets.

@brycejacobson
brycejacobson / config
Created July 19, 2017 15:17
Fix Sublime Text SSH Passphrase Issue on Mac
Add the following to "~/.ssh/config" file:
Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
UseKeychain yes
@brycejacobson
brycejacobson / functions.php
Last active August 16, 2017 14:50
Auto-populate Custom Post Type Title with ACF field.
<?php
// Auto-populate Staff post title with ACF name field.
function efd_staff_post_title_updater($post_id)
{
$my_post = array();
$my_post['ID'] = $post_id;
if (get_post_type() == 'staff') {
$my_post['post_title'] = get_field('name'); // Update Title
$my_post['post_name'] = get_field('name'); // Update Slug
@brycejacobson
brycejacobson / functions.php
Last active April 4, 2025 05:07
Add message to WooCommerce email if shipping method is local pickup.
<?php
add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
function add_order_email_instructions( $order, $sent_to_admin ) {
$shipping_method = @array_shift( $order->get_shipping_methods() );
$shipping_method_id = $shipping_method['method_id'];
if ( ! $sent_to_admin ) {
@brycejacobson
brycejacobson / page.php
Last active December 13, 2016 21:45
WordPress Foundation 6 Video Grid with Advance Custom Fields Repeater
<?php
// check if the repeater field has rows of data
if (have_rows('video_grid')): ?>
<div class="row">
<div class="small-12 small-centered medium-10 columns">
<ul class="small-block-grid-1 medium-block-grid-2">
<?php
// loop through the rows of data
while (have_rows('video_grid')) : the_row();
@brycejacobson
brycejacobson / video.js
Last active December 13, 2016 15:23
Add flex-video class to embedded videos in WordPress
jQuery('iframe[src*="youtube.com"], iframe[src*="vimeo.com"]').each(function() {
if ( jQuery(this).innerWidth() / jQuery(this).innerHeight() > 1.5 ) {
jQuery(this).wrap("<div class='widescreen flex-video'/>");
} else {
jQuery(this).wrap("<div class='flex-video'/>");
}
});
@brycejacobson
brycejacobson / page.php
Created March 4, 2015 17:48
WordPress Loop inside foreach to get posts under custom taxonomy.
<!-- Begin custom tax loop -->
<ul class="accordion" data-accordion>
<?php
//Retrieve custom taxonomy terms using get_terms and the custom post type.
$categories = get_terms('state');
//Iterate through each term
foreach ( $categories as $category ) :
?>
<?php
// WP_Query arguments
$args = array (
'post_type' => 'sermon',
'posts_per_page' => '12',
'post_parent' => 0
);
// The Query
@brycejacobson
brycejacobson / single-sermon.php
Created August 4, 2014 02:44
Sermon Single Page
<?php $level = count(get_post_ancestors( $post->ID )) + 1; // Finding out if we are on a child post
$postid = get_the_ID(); // Getting the id of the current post to find the post_parent below
switch($level) {
case 1:
// WP_Query arguments
$args = array (
'post_type' => 'sermon',
'posts_per_page' => -1,
'post_parent' => $postid,
@brycejacobson
brycejacobson / functions.php
Created April 24, 2014 14:32
Add custom post types to archives in WordPress
<?php
// Add custom post types to archives
function namespace_add_custom_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_types = get_post_types( '', 'names' );
$query->set( 'post_type', $post_types);
return $query;
}
}
@brycejacobson
brycejacobson / functions.php
Created April 16, 2014 18:06
Set slider defaults in v2 of Soliloquy.
<?php
/**
* Add Soliloquy defaults.
*/
add_filter( 'soliloquy_defaults', 'tgm_soliloquy_default_settings', 20, 2 );
function tgm_soliloquy_default_settings( $defaults, $post_id ) {
$defaults['slider_width'] = 800; // Slider width.
$defaults['slider_height'] = 400; // Slider height.
$defaults['control'] = 0; // Turns navigation pagination off by default.