Skip to content

Instantly share code, notes, and snippets.

davechu

Block or report user

Report or block davechu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davechu
davechu / Utility Pro small bugfix
Last active Jul 19, 2016
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.
View Utility Pro small bugfix
// 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 Jul 12, 2016
"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.
View PHP literal text example
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 / Alter "You are here" on breadcrumbs in Genesis
Created Oct 2, 2015
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.
View Alter "You are here" on breadcrumbs in Genesis
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 Sep 22, 2015
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. :)
View Remove link from Auberge WordPress theme Featured Images
@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 Sep 17, 2015
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!
View If using an SEO plugin with Genesis, remove the duplicate meta description as well as Genesis SEO meta boxes on Posts and Pages.
// 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 Sep 9, 2015
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.
View Genesis generic attribute filtering examples
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 Sep 9, 2015
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! :)
View add attribute to sidebar in Genesis
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 Sep 4, 2015
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. :)
View Adding HEAD attribute in Genesis for WordPress
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;
}
@davechu
davechu / Landing page template that is usable in Genesis without loading the framework.
Last active Aug 29, 2015
This will include the file something.php, which may contain any desired HTML and PHP. It's cleaner than using a huge bunch of remove_action statements, and is especially nice if you don't want lots of unnecessary empty markup. Obviously you'll want to make sure the HTML in something.php is complete and valid. :)
View Landing page template that is usable in Genesis without loading the framework.
<?php
/*
Template Name: Landing
*/
get_template_part('something');
@davechu
davechu / Adding HTML before and after WordPress menu item text
Last active Aug 29, 2015
For Maira. This goes in functions.php of your theme, or possibly in a plugin. If you took out the "theme_location" qualifier, it could affect all menus.
View Adding HTML before and after WordPress menu item text
add_filter( 'wp_nav_menu_args', 'dc_modify_nav_menu_args' );
function dc_modify_nav_menu_args( $args )
{
if ( 'primary' == $args['theme_location'] ) {
$args['link_before'] = '<span>';
$args['link_after'] = '</span>';
}
return $args;
}
You can’t perform that action at this time.