Sometimes you may need to access variables from the parent page inside Repeater Templates – the quickest and easiest way to accomplish this is to use PHP Session variables to pass values from your page template to Repeater Template.
In the following example we set a $_SESSION variable in the page template and access the variable in the Repeater Template.
In the page template, before the [ajax_load_more] shortcode we set a $_SESSION[‘parent_slug’] variable that will be accessible in Repeater Templates.
In the repeater template we access the $_SESSION variable and append the value of $_SESSION[‘parent_slug’] to the template container for conditional styling.
Note: Remember to set session_start() at the very top of your page template and Repeater Template.
« Back to Code Samples