Tell us what you are trying to do? We are having tours (products) and a CPT reviews. I like to get single fields using a short code to get different information - based on the field attribute.
Is there a similar example that we can see? Not yet...
But what I tried to do is the following code, but it not working:
function get_my_review($atts) {
global $post;
$str = '';
$origin_id = $post->ID;
$relationship_slug = 'my-tour-id';
$field_value = get_post_meta($post->ID,'wpcf-'.$atts['field'],true);
$results = toolset_get_related_posts (
// get posts related to this one
$origin_id, // get posts connected to this one
$relationship_slug, // in this relationship
array(
'query_by_role' => 'parent', // origin post role
'role_to_return' => 'child', // role of posts to return
'return' => 'post_id', // return array of IDs (post_id) or post objects (post_object)
'limit' => 999, // max number of results
'offset' => 0, // starting from
'args' => array(
'meta_key' => $field_value,
),
)
);
if($atts['field']=='author-first-name' and !empty($field_value)) {
$str .= $field_value;
}
return $str;
}
/* use on template [show_my_review field="author-first-name"] */
add_shortcode( 'show_my_review', 'get_my_review' );