简体   繁体   中英

Using Pods CMS with Roots Wordpress Theme

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?

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 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM