ALM variables are undefined when using get_template_part() method
-
Hey
I’m struggling to find a way to pass PHP variables like
$alm_item
to my default template, which I’ve set up using get_template_part() and some conditionals checking for certain choices in the customizer, like so:<?php if (get_theme_mod( 'zendroidcore-archive-post-layout' ) == 'value1' ) { get_template_part('partials/side-by-side-ajax', 'snippet' ); } elseif (get_theme_mod('zendroidcore-archive-post-layout') == 'value2' ) { get_template_part('partials/over-and-under-ajax', 'snippet' ); } elseif (get_theme_mod('zendroidcore-archive-post-layout') == 'value3' ) { get_template_part('partials/masonry-ajax', 'snippet' ); } else {} ?>
They just throw an undefined variable error. I tried setting them to global at the top of the template but that didn’t have any effect, and also tried passing them using a Session and that didn’t help either.
All I’m trying to do is get a count of each post in the ALM loop so I can style the first one individually (it’s going to need different markup structure to achieve what I need to do so CSS
nth-of-type
or anything like it won’t work here).I’d be very grateful for a pointer on what I’m doing wrong with it! Otherwise I’ve had a flawless experience with the plugin, it’s superb and I’ll definitely be upgrading to paid addons as soon as I can.
Thanks,
Jason
- The topic ‘ALM variables are undefined when using get_template_part() method’ is closed to new replies.