How to Create a Recipe or Photo Index in Genesis

These templates/snippets will work only if you have the Genesis Framework installed and a child theme active.  This will provide a graphic / image based index of your photos or recipes categories.

Image Index for Recipes or Photos

Image Index from FramedCooks.com

Before you start, you’ll need this:

  • FTP access
  • Text / Code editor
  • All posts for this index in one big category, for example, “Recipes” with all the sub-categories below that.  Each post/recipe should be placed in one of the sub-categories.
  • The ID of the main category
WARNING: adding this code to your site can break it entirely – cause it not to show up.  I recommend making changes to your files via FTP and only after you’ve taken a backup!!

1. Create the Main Image Index Page

Create a new Page (not post) and simply create a gallery of your favorite images – one representing each sub-category.  In the above image, the sub-categories were Appetizers, Breakfast & Brunch, Lunch and so on.  Then style appropriately.  Link each of these images to your sub-categories.

Now we’ll create the templates for each sub-category to automatically display all the latest yummy-ness or photos.

2. Test for child categories using a custom function

Add this to your child theme’s functions.php:

//by ValenDesigns.com

// If is category or subcategory of $cat_id
if (!function_exists('is_category_or_sub')) {
        function is_category_or_sub($cat_id = 0) {
            foreach (get_the_category() as $cat) {
                if ($cat_id == $cat->cat_ID || cat_is_ancestor_of($cat_id, $cat)) return true;
            }
            return false;
        }
} 

3. Add an archive.php template to Genesis child theme

Add this file in its entirety to your child theme folder and name it archive.php.  If you already have an archive template, this will NOT work – you’ll need to add these functions carefully to the existing file so you don’t disable current functions.

';
        $title .= single_term_title('', false );
        $title .= '';
        echo $title;
}

//list subcategories or siblings 
function dswp_listsubcats () {
        foreach (get_the_category('') as $category);
        $cat = get_query_var('cat'); 
        $cat_id=$category->cat_ID;
        $child_cats = get_categories('child_of='.$cat);
                if ($child_cats) { $args = array(
    'title_li' => '',
    'depth' => 1,
    'echo' => 1,
    'child_of' => $cat
    ); ?>