Skip to content

Instantly share code, notes, and snippets.

@davechu
davechu / Utility Pro small bugfix
Last active July 19, 2016 19:41
This change's purpose is to correctly remove Backstretch from pages that use the Utility Pro landing page. This fix goes in enqueue-assets.php.
// Load remaining scripts only if custom background is being used
// and we're on the home page or a page using the landing page template
// dave bugfix - had to move the "not" to be specifically on is_front_page to take backstretch out of landing page.
if ( ! get_background_image() || ( ( ! is_front_page() || is_page_template( 'page_landing.php' ) ) ) ) {
return;
}
/*** old code so you can see what changed.
if ( ! get_background_image() || ( ! ( is_front_page() || is_page_template( 'page_landing.php' ) ) ) ) {
@davechu
davechu / PHP literal text example
Last active July 12, 2016 13:47
"EOT" marks the beginning and end of the text string. Note the last line, which must begin at the beginning of a new line or it won't work.
echo <<< EOT
<div class="customLogos">
<div class="cLogoHolder">
<a href="https://www.www.com/"><img src="/wp-content/themes/x/tribe-events/community/images/www.png" alt="" /></a>
<a href="http://www.www.com/"><img src="/wp-content/themes/x/tribe-events/community/images/www_edited.png" alt="" /></a>
</div>
</div>
EOT;
@davechu
davechu / Genesis Auto Submenu
Last active February 1, 2016 15:28
This is code that will allow the use of Christian Varga's handy WordPress auto-submenu code.
/** dave's genesis code for making the submenu **/
add_action( 'wp_head', 'dc_add_tricky_menu' );
function dc_add_tricky_menu () {
// make all menus one level, or else dropdowns will be redundant in your submenu.
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
// stick submenu under main menu. Of course you can use other hooks to put menu & submenu elsewhere.
add_action( 'genesis_after_header', 'dc_add_tricky_two' );
}
function my_wp_nav_menu_args( $args = '' ) {
@davechu
davechu / Changing title attributes
Created July 29, 2014 14:42
For Veit. Here's how to change itemprop for site title or entry title in Genesis. These go in your functions.php of your child theme.
add_filter( 'genesis_attr_site-title', 'dc_veit_site_title' );
function dc_veit_site_title( $attributes ) {
$attributes['itemprop'] = 'nonheadline';
return $attributes;
}
add_filter( 'genesis_attr_entry-title', 'dc_veit_entry_title' );
function dc_veit_entry_title( $attributes ) {
$attributes['itemprop'] = 'whatever';
return $attributes;
@davechu
davechu / Alter "You are here" on breadcrumbs in Genesis
Created October 2, 2015 18:48
For Bjorne. This bit of code goes in your theme's functions.php. Notice how I have 2 variations, the commented one removes that completely, the next one replaces the original text.
add_filter( 'genesis_breadcrumb_args', 'dc_breadcrumb_args' );
function dc_breadcrumb_args( $args ) {
//$args['labels']['prefix'] = '';
$args['labels']['prefix'] = 'Du är här';
return $args;
}
@davechu
davechu / Remove link from Auberge WordPress theme Featured Images
Created September 22, 2015 19:56
When you make a child theme of Auberge, you can use this code in your functions.php to remove the links from Featured Images on pages. If this sounds scary, ask a developer to do it. :)
@davechu
davechu / If using an SEO plugin with Genesis, remove the duplicate meta description as well as Genesis SEO meta boxes on Posts and Pages.
Last active September 17, 2015 18:14
Genesis SEO settings do have some code that will disable parts of itself when it "sees" certain SEO plugins. I wanted to disable more, including a duplicate Meta Description tag (possibly a bug). I had also tried the command that simply shuts of all of Genesis SEO, but that knocked the page titles out of my theme!
// kill genesis meta description when using another SEO plugin. also remove genesis SEO metas from posts.
remove_action( 'genesis_meta','genesis_seo_meta_description' );
remove_action( 'admin_menu', 'genesis_add_inpost_seo_box' );
@davechu
davechu / Genesis generic attribute filtering examples
Created September 9, 2015 19:25
The idea is to use the genesis_attr_{some-class-or-html-tag} format. Your class (or HTML tag) must only occur once on the page for it to work. Notice that I concatenate the class so that existing classes don't get lost.
add_filter( 'genesis_attr_site-inner', 'dc_modify_site_inner_attr' );
function dc_modify_site_inner_attr( $attributes ) {
$attributes['itemtype'] = 'http://schema.org/Report';
$attributes['class'] .= ' myNewClass';
return $attributes;
}
add_filter( 'genesis_attr_head', 'dc_modify_head_attr' );
function dc_modify_head_attr( $attributes ) {
$attributes['itemtype'] = 'http://schema.org/Report';
@davechu
davechu / add attribute to sidebar in Genesis
Last active September 9, 2015 16:35
For emmtre. In place of sidebar-primary, sidebar-secondary and footer-widgets should also work. Notice how I'm concatenating the class and leaving a space; if you just assign a value to it, you'll remove your other classes from the sidebar, and the visual results will be dramatic! :)
add_filter( 'genesis_attr_sidebar-primary', 'dc_modify_widget_area_attr' );
function dc_modify_widget_area_attr( $attributes ) {
$attributes['itemtype'] = 'http://schema.org/CreativeWork';
$attributes['class'] .= ' prettyproduct';
return $attributes;
}
@davechu
davechu / Adding HEAD attribute in Genesis for WordPress
Last active September 4, 2015 16:03
You can add any attribute you like to the HEAD tag. As you can see, I added a joke one here under the real one. :)
add_filter( 'genesis_attr_head', 'dc_modify_head_attr' );
function dc_modify_head_attr( $attributes ) {
$attributes['itemtype'] = 'http://schema.org/Article';
$attributes['bogusnewthing'] = 'brandnewwhatever';
return $attributes;
}