Skip to content

Instantly share code, notes, and snippets.

View rickrduncan's full-sized avatar

Rick R. Duncan rickrduncan

View GitHub Profile
@rickrduncan
rickrduncan / google-cse-1.php
Last active December 25, 2015 05:49
Step 1: Google CSE for WordPress/Genesis Framework
<?php
//* Do NOT include the opening php tag above
add_filter( 'genesis_search_form', 'rvam_search_form', 10, 4);
function rvam_search_form( $form, $search_text, $button_text, $label ) {
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\"";
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\"";
$form = '<form method="get" class="searchform search-form" action="' . home_url() . '/search" >' . $label . '
<input type="text" value="' . esc_attr( $search_text ) . '" name="q" class="s search-input"' . $onfocus . $onblur . ' />
<input type="submit" class="searchsubmit search-submit" value="' . esc_attr( $button_text ) . '" />
@rickrduncan
rickrduncan / google-cse-2.php
Last active December 25, 2015 05:49
Step 2: Google CSE for WordPress/Genesis Framework
<?php
//* Do NOT include the opening php tag above
genesis_register_sidebar( array(
'id' => 'google-cse',
'name' => __( 'Google CSE Page', 'CHILD_THEME_NAME' ),
'description' => __( 'This is the widget area of the Google CSE Page Template.', 'CHILD_THEME_NAME' ),
) );
@rickrduncan
rickrduncan / google-cse-genesis.php
Last active November 19, 2016 13:50
Google CSE for WordPress/Genesis Framework
<?php
/*
* Template Name: Google CSE
*
* This file adds the Google SERP template to our Genesis Child Theme.
*
* @author Rick R. Duncan
* @link http://rickrduncan.com
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
*
@rickrduncan
rickrduncan / google-cse.js
Last active December 25, 2015 06:29
Add Google CSE to WordPress websites using the Genesis Framework.
<script>
(function() {
var cx = '007935457329138067308:j8ssm1gufja';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
<?php
//* Do NOT include the opening php tag above
/**
* Alter the Genesis Search form so that we can change the destination page
* and our querystring parameter.
*
* @author Rick R. Duncan
* @link http://www.rickrduncan.com
*/
@rickrduncan
rickrduncan / genesis-page-titles-html5.php
Last active August 1, 2022 11:16
How to remove page titles from Genesis child themes using XHTML and HTML5 methods.
<?php
//* Do NOT include the opening php tag
//* ALL EXAMPLES ON THIS PAGE USE THE NEW HTML5 METHOD
//* Remove page titles site wide (posts & pages) (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
@rickrduncan
rickrduncan / genesis-body-filter-schema.php
Last active December 25, 2015 10:48
Genesis 2.0 - Filter schema attributes for body element.
<?php
//* Do NOT include the opening php tag
//* Change microdata schema when on the About or Contact page.
//* http://schema.org/docs/documents.html
//* genesis/lib/functions/markup.php
add_filter( 'genesis_attr_body', 'rvam_body_schema' );
function rvam_body_schema( $attributes ){
//* Use AboutPage schema on our about page
@rickrduncan
rickrduncan / author-breadcrumb.php
Last active October 22, 2020 08:54
Customize Genesis breadcrumb
<?php
//* Do NOT include the opening php tag
//* Prefix author breadcrumb trail with the text 'Articles written by'
add_filter( 'genesis_breadcrumb_args', 'b3m_prefix_author_breadcrumb' );
function b3m_prefix_author_breadcrumb( $args ) {
$args['labels']['author'] = 'Articles written by ';
return $args;
@rickrduncan
rickrduncan / grunion.php
Created January 14, 2014 13:36
Remove grunion.css: This will remove the stylesheet used for JetPack's contact form thereby allowing you to write your own styles and not having to resort to using !important all over the place. The code should be placed in your functions.php file.
<?php
//* Do NOT include the opening php tag
//* Remove JetPack's grunion stylesheet used for the contact form
function remove_grunion_style() {
wp_deregister_style('grunion.css');
}
add_action('wp_print_styles', 'remove_grunion_style');
@rickrduncan
rickrduncan / enqueue-core.php
Last active January 3, 2016 07:09
jQuery for smooth scrolling to top of page.
<?php
//* Do NOT include the opening php tag
//* Add Core JS file
add_action( 'wp_enqueue_scripts', 'b3m_add_core_js' );
if ( ! function_exists( 'b3m_add_core_js' ) ) {
function b3m_add_core_js() {
wp_enqueue_script( 'core-js', get_stylesheet_directory_uri() . '/lib/js/core.js', array('jquery'), '1.0.0', true );
}
}