This support ticket is created Il y a 3 années et 4 mois. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
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' );