Skip to content

Instantly share code, notes, and snippets.

@secretstache
secretstache / current-menu-item.php
Last active August 29, 2015 14:10
Dynamically add current-menu-item to list items
<?php $story_nav = new WP_Query( $args ); ?>
<?php if ( ! empty( $story_nav ) ) { ?>
<?php $queried_object = get_queried_object(); ?>
<?php $current_page_id = $queried_object->ID; ?>
<ul class="featured-stories">
<li>Featured Stories
@secretstache
secretstache / admin-body-class-home.php
Last active August 29, 2015 14:13
Adds a unique body class to the editor screen of a specific page, in this case the home page
add_filter( 'admin_body_class', 'ssm_home_admin_body_class' );
/*
* Adds a body class to target the home page edit screen
*
*/
function ssm_home_admin_body_class( $classes ) {
global $post;
$screen = get_current_screen();
$homepage = get_page_by_title( 'Home' );
@secretstache
secretstache / acf-soliloquy.php
Created February 26, 2015 22:11
Dynamic Soliloquy Slideshow using ACF
<?php
add_action( 'genesis_after_header', 'ssm_insert_slideshow', 99 );
/**
* Builds the HTML for the homepage slideshow
*
*/
function ssm_insert_slideshow() { ?>
<?php if ( $slides = get_field( 'slides' ) ) { ?>
@secretstache
secretstache / layout.php
Created March 24, 2015 19:22
force content sidebar genesis
//* Force content-sidebar layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
@secretstache
secretstache / cart66-viewcart.php
Created April 8, 2015 16:35
Cart 66 Shortcode for View Cart
//Filter Through Store Nav
add_filter( 'wp_nav_menu_items', 'ssm_append_store_navigation', 10, 2 );
function ssm_append_store_navigation ( $items, $args ) {
if ( do_shortcode('[cc_cart_item_count]') == 1 ) {
$cart_item = '<li class="right cart"><a href="' . get_bloginfo('url') . '/view_cart/">' . do_shortcode('[cc_cart_item_count]') . ' Item</a></li>';
} else {
@secretstache
secretstache / acf-cac.php
Created April 8, 2015 23:41
Append ACF Post Object to Admin Column Pro Filter Dropdown
<?php
/**
* Filter the Admin Column results
*
*/
function my_cac_filtering_options_change_acf_label( $options, $column ) {
$column_type = 'column-acf_field'; // enter type of field. You can find this by hovering of the Type label of the column settings.
$field_label = 'Product Class'; // enter label of the ACF field.
@secretstache
secretstache / gfm.php
Last active January 9, 2016 00:14
Genesis Markup for Foundation
<?php
function ssfg_add_markup_class( $attr, $context ) {
// default classes to add
$classes_to_add = apply_filters ('ssfg-classes-to-add',
// default foundation markup values
array(
'site-header' => 'row',
'site-container' => 'inner-wrap',
'site-footer' => 'row',
'content-sidebar-wrap' => 'row',
@secretstache
secretstache / gist:9f0a93a9953361edb7bb
Last active February 4, 2016 07:10
Get First Instance of Visual Editor Content Block
<?php
/*
* Returns the first instance of a given layout option
* @param - $id - the id of the post you are trying to target: '' by default
* @param - $fc_field - the name of the ACF flexible field: 'content_blocks' as the default
* @param - $fc_layout - the name of the flexible content layout: 'visual_editor' as the default
* @return - mixed
* @todo - test different types of returned content. at the moment, I am only using this for returning a string
*/
function get_first_instance_of_content_block( $id = '', $fc_field = 'content_blocks', $fc_layout = 'visual_editor' ) {
@secretstache
secretstache / data-attributes.php
Created July 28, 2016 16:48
data attributes for genesis
add_filter( 'genesis_attr_site-container', 'ssm_data_off_canvas_content' );
function ssm_data_off_canvas_content($attributes) {
$attributes['data'] = 'data-off-canvas-content';
return $attributes;
}
// this creates <div class="site-container" data='data-off-canvas-content'></div>
// is there a way to do something like <div class="site-container" data-off-canvas-content></div>
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_5525dfd96b4a0',
'title' => 'Brand Logo',
'fields' => array (
array (
'key' => 'field_5525dff1be331',