Last active
May 8, 2025 17:36
-
-
Save Crocoblock/f1eba1214c0adc0a2eba609052ca790a to your computer and use it in GitHub Desktop.
Get current JetEngine listing object meta value ( somewhat similar to ACF get_field() )
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 | |
//You may just use get_post_meta() / get_term_meta() / get_user_meta() to get post/term/user meta | |
//However, in Listing Grid, you may use get_meta() method for convenience | |
$value = jet_engine()->listings->data->get_meta( $meta_key, $object ); | |
/** | |
* Get object meta value. Works for Posts, Terms, Users, Comments | |
* $object defaults to null, then the value will be retrieved from the current listing object | |
* Example: the current object is a Post, | |
* the meta key is 'age' | |
* the meta value is 42 | |
*/ | |
$value = jet_engine()->listings->data->get_meta( 'age' ); | |
//$value is 42 | |
/** | |
* To get the value from the post, different from the current listing object, pass that object as the second argument | |
* Example: post ID is 512 | |
* the meta key is 'age' | |
* the meta value is 24 | |
* Current listing post 'age' meta value is 48 | |
*/ | |
$object = get_post( 512 ); | |
$value = jet_engine()->listings->data->get_meta( 'age', $object ); | |
//$value is 24, as we get meta value from $object, which is a post with ID of 512 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment