Skip to content

Instantly share code, notes, and snippets.

@sungsoonz
Created February 23, 2017 07:00
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 sungsoonz/95ebe72fdf12ef2c3ca5d4acaa0397a6 to your computer and use it in GitHub Desktop.
Save sungsoonz/95ebe72fdf12ef2c3ca5d4acaa0397a6 to your computer and use it in GitHub Desktop.
<?php
/**
* Front page template
*
* @package Gone Frying
* @author Seong Lee
* @link http://www.seonglee.com/
* @copyright Copyright (c) 2017, Seong Lee
* @license GPL-2.0+
*/
add_action( 'genesis_meta', 'gf_home_page_setup' );
/**
* Set up the homepage layout by conditionally loading sections when widgets
* are active.
*
* @since 1.0.0
*/
function gf_home_page_setup() {
$home_sidebars = array(
'home_welcome' => is_active_sidebar( 'home-welcome' ),
'call_to_action' => is_active_sidebar( 'call-to-action' ),
);
// Return early if no sidebars are active.
if ( ! in_array( true, $home_sidebars ) ) {
return;
}
// Add home welcome area if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome'] ) {
add_action( 'genesis_after_header', 'gf_add_home_welcome' );
}
// Add call to action area if "Call to Action" widget area is active.
if ( $home_sidebars['call_to_action'] ) {
add_action( 'genesis_after_header', 'gf_add_call_to_action' );
}
// Force full-width-content layout setting.
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
// Remove posts.
remove_action( 'genesis_loop', 'genesis_do_loop' );
}
/**
* Display content for the "Home Welcome" section.
*
* @since 1.0.0
*/
function gf_add_home_welcome() {
genesis_widget_area( 'home-welcome',
array(
'before' => '<div class="home-welcome"><div class="wrap">',
'after' => '</div></div>',
)
);
}
/**
* Display content for the "Call to Action" section.
*
* @since 1.0.0
*/
function gf_add_call_to_action() {
genesis_widget_area( 'call-to-action',
array(
'before' => '<div class="call-to-action"><div class="wrap">',
'after' => '</div></div>',
)
);
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment