Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
bryanwillis / functions.php
Last active August 29, 2015 14:25 — forked from levymetal/direct_parent.php
Custom Wordpress function which uses a nav walker to display a list of child pages from a common parent, which can be called from either the parent page (displays children) or any of the child pages (displays siblings). Detailed instructions available on my blog post here: http://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-…
<?php
// add hook
add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects_sub_menu', 10, 2 );
// filter_hook function to react on sub_menu flag
function my_wp_nav_menu_objects_sub_menu( $sorted_menu_items, $args ) {
if ( isset( $args->sub_menu ) ) {
$root_id = 0;
@bryanwillis
bryanwillis / gist:a1e8cbfc5e9211b1896f
Last active August 29, 2015 14:25 — forked from johnmorris/gist:5245822
Hijacking WordPress menus using wp_nav_menu_objects
if ( !class_exists( 'HijackMe' ) ) {
class HijackMe {
public function hijack_menu($objects) {
/**
* If user isn't logged in, we return the link as normal
*/
if ( !is_user_logged_in() ) {
return $objects;
}
/**
@bryanwillis
bryanwillis / wordpress-hide-editor-on-pages.php
Last active September 11, 2015 06:21 — forked from atomtigerzoo/wordpress-hide-editor-on-pages.php
Wordpress: Hide the editor on defined pages
/**
* Hide the main editor on specific pages
*/
define('EDITOR_HIDE_PAGE_TITLES', json_encode(array()));
define('EDITOR_HIDE_PAGE_TEMPLATES', json_encode(array('template-cars.php')));
/**
* Hide the main editor on defined pages
*
@bryanwillis
bryanwillis / functions.php
Created November 15, 2015 21:20 — forked from mafsdisseny/functions.php
Add genesis-structural-wrap and filter it through a template
<?php
// First we include it in the genesis-structural-wrap genesis declaration
add_theme_support( 'genesis-structural-wraps', array(
'header',
// 'nav',
// 'subnav',
'site-inner',
'footer-widgets',
'page-header-img', //here is it
'footer'
@bryanwillis
bryanwillis / functions.php
Created December 4, 2015 00:21 — forked from robincornett/functions.php
optional home.php--to show the posts page's title and content
<?php
// do NOT include the opening line! Just add what's below to the end of your functions.php file
add_action( 'edit_form_after_title', 'rgc_posts_page_edit_form' );
function rgc_posts_page_edit_form() {
global $post, $post_type, $post_ID;
if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
add_post_type_support( $post_type, 'editor' );
}
@bryanwillis
bryanwillis / homeloop.php
Created December 5, 2015 20:11 — forked from neilgee/homeloop.php
Custom Genesis Home Loop with Character Limitation on Excerpt
<?php
//do not add in opening php tag
/**
* Custom Genesis Home Loop with Character Limitation on Excerpt
*
* @package Custom Genesis Home Loop with Character Limitation on Excerpt
* @author Neil Gee
* @link http://wpbeaches.com
* @copyright (c)2014, Neil Gee
@bryanwillis
bryanwillis / functions.php
Last active January 11, 2016 09:18 — forked from srikat/functions.php
Wrapping Primary and Secondary Navigation in custom divs in Genesis
//* Wrap .nav-primary in a custom div
add_filter( 'genesis_do_nav', 'genesis_child_nav', 10, 3 );
function genesis_child_nav($nav_output, $nav, $args) {
return '<div class="nav-primary-wrapper">' . $nav_output . '</div>';
}
//* Wrap .nav-secondary in a custom div
add_filter( 'genesis_do_subnav', 'genesis_child_subnav', 10, 3 );
@bryanwillis
bryanwillis / acf_gen_attr01.php
Created December 15, 2015 08:18 — forked from SiGaCode/acf_gen_attr01.php
Use genesis_attr to add inline styles via ACF
// Add background-color to .footer-widgets
add_filter( 'genesis_attr_footer-widgets', 'ap_attributes_footer_widgets' );
function ap_attributes_footer_widgets( $attributes ) {
$background = get_field('footer_widgets_bg', option);
$attributes['style'] = 'background-color:' . $background . ';';
return $attributes;
}
//* Add the site tagline section
add_action( 'genesis_after_header', 'minimum_site_tagline' );
function minimum_site_tagline() {
if (is_home() )
printf( '<div %s>', genesis_attr( 'site-tagline' ) );
genesis_structural_wrap( 'site-tagline' );
printf( '<div %s>', genesis_attr( 'site-tagline-left' ) );
printf( '<p %s>%s</p>', genesis_attr( 'site-description' ), esc_html( get_bloginfo( 'description' ) ) );
echo '</div>';
<?php
/**
* This file adds widgetized Home Page.
*
*/
add_action( 'get_header', 'prefix_home_genesis_meta' );
/**
* Add widget support for homepage. If no widgets active, display the default loop.
*