2

I am having problems displaying Pods data in a custom Wordpress template using the Roots Theme

I have setup a "Products" Pod, a Pods page "products/*" that has been assigned the custom Wordpress template. Roots uses a Theme Wrapper file that doesn't appear to work on Pods pages. Has anyone come across this before and perhaps found a solution?

SinDesign
  • 41
  • 1
  • 1
  • 7
  • I ended up creating a new page setting the appropriate template. Last, I added a new wordpress route using `add_rewrite_rule`. `add_rewrite_rule('locations/([^/]+)/?$', 'index.php?pagename=permalink&something=$matches[1]', 'top');` – Chris McKnight Dec 27 '13 at 23:18

2 Answers2

0

You can add a custom template and put pods_content() in it where you want to output the content.

Or you can hook into get_template_part_templates/content and check the second value for 'page' and then run the pods_content() there.

add_action( 'get_template_part_templates/content', 'hook_into_pods_page', 2 );

function hook_into_pods_page ( $slug, $name ) {
    if ( is_pod_page() && 'page' == $name )
        pods_content();
}
  • I have previously tried the using `pods_content()` in a template as shown in your docs [here](http://podsframework.org/codex/wp_templates) but it doesn't output any data? The solution I like best for displaying Pods data is using this tutorial from [Monday By Noon](http://mondaybynoon.com/20100104/pulling-pods-data/) which works nicely, just have the issue with the theme wrapper... – SinDesign Apr 03 '13 at 01:15
0

I have no idea if this is a "good" solution or not. I started using Wordpress yesterday.

That said, here's my solution which seems to work well.

In your pods page templates put the output for the page into $pods_content

$pods_content = $cookie->template('', get_pod_template('market-single'));
ob_start();
include get_stylesheet_directory() . '/base.php';
print ob_get_clean();

Then in base.php replace the roots_template_path include with this:

if ($pods_content): print $pods_content; else: include roots_template_path(); endif;
Joren
  • 9,623
  • 19
  • 63
  • 104