Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save feastdesignco/6869076 to your computer and use it in GitHub Desktop.
Save feastdesignco/6869076 to your computer and use it in GitHub Desktop.
Add A Widgetized Recipe Index to the Foodie Child Theme - you MUST edit this code to make it work.
<?php
/**
* Template Name: Recipe Index
*
* @category Foodie
* @subpackage Genesis
* @copyright Copyright (c) 2013, Shay Bocks
* @license GPL-2.0+
* @link http://www.shaybocks.com/foodie/
* @since 1.0.0
*
*/
add_action( 'genesis_meta', 'foodie_recipes_genesis_meta' );
/**
* Add widget support for recipes page.
* If no widgets active, display the default page content.
*
* @since 1.0.0
*/
function foodie_recipes_genesis_meta() {
if ( is_active_sidebar( 'recipes-top' ) || is_active_sidebar( 'recipes-bottom' ) ) {
// Force a full width layout.
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
// Remove the default Genesis loop.
remove_action( 'genesis_loop', 'genesis_do_loop' );
// Add a custom loop for the home page.
add_action( 'genesis_loop', 'foodie_recipes_loop_helper' );
}
}
/**
* Display the recipe page widgeted sections.
*
* @since 1.0.0
*/
function foodie_recipes_loop_helper() {
if ( is_active_sidebar( 'recipes-top' ) || is_active_sidebar( 'recipes-left' ) || is_active_sidebar( 'recipes-right' ) ) {
// Add the top recipes section if it has content.
if ( is_active_sidebar( 'recipes-top' ) ) {
genesis_widget_area( 'recipes-top', array(
'before' => '<div class="widget-area recipes-top">',
'after' => '</div> <!-- end .recipes-top -->',
) );
}
// Add the bottom recipes section if it has content.
if ( is_active_sidebar( 'recipes-bottom' ) ) {
genesis_widget_area( 'recipes-bottom', array(
'before' => '<div class="widget-area recipes-bottom">',
'after' => '</div> <!-- end .recipes-bottom -->',
) );
}
}
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment