Created
June 14, 2024 09:57
-
-
Save MjHead/7b58ca06b8e51a1295dba6b807be9e59 to your computer and use it in GitHub Desktop.
JetEngine. Timber/Twig listings. Set Post context for WC Product Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'jet-engine/twig-views/current-context', function( $context, $object ) { | |
if ( is_a( $object, 'WC_Product' ) ) { | |
$object_factory = new \Jet_Engine\Timber_Views\Object_Factory(); | |
$context['post'] = $object_factory->get_post( get_post( $object->get_id() ) ); | |
} | |
return $context; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment