Genesis Framework

Overview

The Genesis Framework is a very popular and powerful WordPress theme framework. Pods integrates well with Genesis when you need to add custom content types and fields.

Adding Post Type Supports

pods-genesis-supportWhen using the Genesis Framework, custom post types can be optionally registered with support for Genesis: SEO, Genesis: Layouts and Genesis: Simple Sidebars. When Genesis is activated as the current theme, you will see options in the Pods editor to enable support for these three Genesis features in the Advanced Options tab for all post type Pods. When checked your post type Pods will work with these features of the Genesis Framework as intended.

Using Pods In The Genesis Loop

If you are using standard meta storage post type Pods, you can use get_post_meta() or the Pods class to retrieve your custom field data inside of the Genesis loop. The same rules apply, as far as the WordPress template heirarchy for Pods custom post types, as any other custom post type. As a result, the typical patten of creating a custom template, named single-{post-type}.php or archive-{post-type}.php applies. The following example shows how to show a text field called “width” in a Genesis single post type template using get_post_meta()

add_action( 'genesis_entry_content', function() { 	echo get_post_meta( get_the_ID(), 'width', true ); });

This example shows the same scenario, using the Pods class:

add_action( 'genesis_entry_content', function() { 	$pods = pods(); 	echo $pods->display( 'width' ); });

If you are using the table storage component to store your post type’s custom fields in a custom table, then you must use the Pods class. If you are using the default meta storage then it is a matter of preference, though using get_post_meta() is preferred.

Loading Pods Templates in the Genesis Loop

Using Pods Templates for your markup is an excellent way to output your custom fields from your WordPress posts types. You can easily output a Pods Template automatically before, after or in place of your posts content using Auto Templates with Pods Templates. Since this acts on the_content filter it works with Genesis as long as you do not prevent that filer from running inside of core Genesis functions, which it does by default. You can create a similar template loader during any hook. For single posts this can work anywhere that the global $post is set. For example, to output a template at the beginning of your footer:

add_action( 'genesis_before_footer', function() { 	global $post; 	$pods = pods( 'pod_name', $post->ID ); 	echo $pods->template( 'template_name' ); });