Newbie confused about how to reference pods data in custom page template
-
I’ve used Pods a bit and can do some simple things with shortcodes in a page but now I’d like to build a custom page where I can display Pods data using the pods object. I’ve copied the page.php to a custompage.php file in my child theme and set a page to that custom template. I can throw some html in that custom template and see it rendered when I view my page so I know that part is working.
However, if I try to access Pods data I don’t get an object. Here’s my snippet
<?php /* * Template Name: Balance Projection * Description: Balance Projection Template */ get_header(); ?> <div id="primary" class="site-content"> <div id="content" role="main"> <?php $mypod = pods( 'balancetransaction' ); if ( $mypod->exists() ) { echo '<p>Exists</p>'; } else { echo '<p>Does not Exist</p>'; } echo '<p>Here</p>'; ?> </div><!-- #content --> </div><!-- #primary -->
When I view this page, I always get “Does not Exist”. Note that I’ve tweaked this code from the original which had a while (have_posts…) loop in it. I tried putting the pods call inside but that didn’t work.
I watched some of the videos on displaying data but they glossed over where all that code was actually going so they were of little help.
Thanks for any help,
Tom
- The topic ‘Newbie confused about how to reference pods data in custom page template’ is closed to new replies.