Access to Options Table in Shortcode Templates
-
Hello,
I am using shortcodes to load various components on to a page, within which I need to access the options table (for some custom site settings).
I have this in my functions.php file:
// Use this function to add variables to the Twig context add_filter('timber_context', 'add_to_context'); function add_to_context( $context ) { $context['options'] = get_fields('option'); return $context; } // Add Instagram shortcode. add_shortcode('sc_instagram-feed', 'instagram_shortcode'); function instagram_shortcode() { return Timber::compile('sc-instagram.twig'); }
Within the template I’m calling the shortcode from, I have access to the ‘options’ object but one I’m ‘in’ the shortcode template I don’t seem to have access to it anymore. Is somehow the Timber context changing?
Any help would be appreciated please.
Thanks,
Chris
- The topic ‘Access to Options Table in Shortcode Templates’ is closed to new replies.