If you need display values of the post/custom which are created by built-in meta data constructor, you can use next function:
1 2 3 4 5 6 7 8 9 | /** Get meta value of post * * @param string $key Meta Key * @param int $post_id Post ID, if its == 0, ID will try to get from globals * @param bool $look_for_reflection Set to true if you now or you think that param is reflected * * @return mixed Depends of what meta field is keeps */ MetaDataFilter::get_field($key, $post_id = 0, $look_for_reflection = false ) |
- If you are using this on the single page you not need set $post_id, if somewhere in loop you need set this value.
- If you are sure that you are using reflection, set $look_for_reflection to true. Do not set it simply just like that, it is creates one more MySQL query else, so if you do not need this - do not use.
- Also you can use next shortcode: [mdf_value post_id=5 key='medafi_price' reflection=1]
Read also: