Skip to content

Instantly share code, notes, and snippets.

@thewebattic
Created February 5, 2014 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thewebattic/8828101 to your computer and use it in GitHub Desktop.
Save thewebattic/8828101 to your computer and use it in GitHub Desktop.
<?php
//* Start the engine
include_once( get_template_directory() . '/lib/init.php' );
//* Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Genesis Sample Theme' );
define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
define( 'CHILD_THEME_VERSION', '2.0.1' );
//* Enqueue Lato Google font
add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
function genesis_sample_google_fonts() {
wp_enqueue_style( 'google-font-lato', '//fonts.googleapis.com/css?family=Lato:300,700', array(), CHILD_THEME_VERSION );
}
//* Add HTML5 markup structure
add_theme_support( 'html5' );
//* Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );
//* Add support for custom background
add_theme_support( 'custom-background' );
//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 2 );
//* Load Backstretch script and prepare images for loading
add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts' );
function genesis_sample_enqueue_scripts() {
// Load scripts only if custom background is being used
if ( ! get_background_image() )
return;
wp_enqueue_script( 'genesis_sample-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'genesis_sample-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'converge-backstretch' ), '1.0.0' );
wp_localize_script( 'genesis_sample-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
}
//* Register after post widget area
genesis_register_sidebar( array(
'id' => 'above-footer',
'name' => __( 'Above Footer', 'genesis_sample' ),
'description' => __( 'This is a widget area that can be placed above the footer', 'genesis_sample' ),
) );
add_action( 'genesis_before_footer', 'above_footer_widget' );
function above_footer_widget() {
genesis_widget_area( 'above-footer', array(
'before' => '<div class="above-footer widget-area">',
'after' => '</div>',
) );
}
//* Register above header widget area
genesis_register_sidebar( array(
'id' => 'above-header',
'name' => __( 'Above header' ),
'description' => __( 'This is a widget area that can be placed above the header' ),
) );
/** Add the Header Widget Area */
add_action( 'genesis_before_header', 'custom_above_header' );
function custom_above_header() {
genesis_widget_area( 'above-header', array(
'before' => '<div class="above-header widget-area">',
'after' => '</div>',
) );
}
function dma_change_post_order(){
if ( is_archive() ){
global $wp_query;
$args = array_merge( $wp_query->query, array( 'orderby' => 'title','order' => 'ASC' ) );
query_posts( $args );
}
}
add_action('genesis_before_loop','dma_change_post_order');
/* Custom sidebar for Contacts Archive Page */
//* Reposition the breadcrumbs
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
add_action( 'genesis_entry_header', 'genesis_do_breadcrumbs' );
// Conditionally remove secondary menu
add_action('template_redirect', 'afn_conditional_actions');
function afn_conditional_actions() {
if ( is_page( array( 6,8,78,80, )) ) {
remove_action('genesis_after_header', 'genesis_do_subnav');
add_action('genesis_after_entry', 'genesis_do_subnav');
}
}
//* Remove post comments in Genesis Framework
remove_action( 'genesis_after_post', 'genesis_get_comments_template' );
// Add div.wrap inside of div#content2
function child_before_content_sidebar_wrap() {
if ( is_page( array( 21,25,23, 'blog' )) ) {
echo '<div id="content3">';
} elseif ( is_page() ) {
echo '<div id="content2">';
} elseif ( is_search() ) {
echo '<div id="content3">';
} elseif (has_excerpt() ) {
echo '<div id="content3">';
} elseif ( is_page_template('blog') ) {
echo '<div id="content3">';
} elseif ( is_single() ) {
echo '<div id="content2">';
}
elseif ( is_post_type_archive() ) {
echo '<div id="content2">';
}
}
add_action('genesis_before_content_sidebar_wrap', 'child_before_content_sidebar_wrap');
function child_after_content_sidebar_wrap() {
echo '</div><!-- end .wrap -->';
}
add_action('genesis_after_content_sidebar_wrap', 'child_after_content_sidebar_wrap');
// Add Script to Genesis child
add_action( 'wp_enqueue_scripts', 'wpsites_register_load_script' );
function wpsites_register_load_script() {
wp_register_script( 'sliding-script', get_stylesheet_directory_uri() . '/js/sliding.js' );
wp_enqueue_script( 'sliding-script' );
}
add_action( 'wp_enqueue_scripts', 'wpsites_load_javascript_conditionally' );
function wpsites_load_javascript_conditionally() {
if ( is_page('page-slug') ) {
wp_enqueue_script( 'sliding-script' );
}
}
add_filter('genesis_noposts_text','my_noposts_text');
function my_noposts_text() {
$my_text = "Rats. I haven't written anything about that yet... try another search.";
return $my_text;
}
//* Register and Enqueue scripts for popup
function cc_popup_script() {
wp_register_script( 'popup', get_stylesheet_directory_uri() . '/js/popup.js', array( 'jquery' ), '1.0.0', false );
wp_enqueue_script( 'popup' );
}
add_action('wp_enqueue_scripts', 'cc_popup_script');
/* Filter for people search Results */
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'contact' )
{
return locate_template('archive-contact.php');
}
return $template;
}
add_filter('template_include', 'template_chooser');
/* Delete text for Tags and Categories www.basicWP.com */
add_filter( 'genesis_post_meta', 'dmp_post_meta_filter' );
function dmp_post_meta_filter($post_meta) {
if (!is_page()) {
$post_meta = '[post_categories sep="/" before=""] [post_tags sep="/" before=""]';
return $post_meta;
} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment