This support ticket is created Il y a 4 années et 1 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.
function get_lessons_for_speaker_func(){
ob_start();
global $post;
$speaker_id = $post->ID;
$relationship_slug = 'lesson-speaker';
$child_posts = toolset_get_related_posts(
$speaker_id , // get posts connected to this one
$relationship_slug, // in this relationship
array(
'query_by_role' => 'child', // origin post role
'role_to_return' => 'parent', // role of posts to return
'return' => 'post_object', // return array of IDs (post_id) or post objects (post_object)
'limit' => 999, // max number of results
'offset' => 0, // starting from
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'need_found_rows' => false, // also return count of results
'args' => null // for adding meta queries etc.
)
);
$arr_m = array_map(function($o) { return "<li><a href='" . get_permalink($o->ID). "'>$o->post_title</a></li>"; }, $child_posts);
$output_string = join(", ", $arr_m);
ob_end_clean();
return "<ul>$output_string</ul>";
}
add_shortcode('get_lessons_for_speaker','get_lessons_for_speaker_func');
The shortcode shows posts which are on draft or supposed to be published in the future.
$relationship_slug = 'lesson-speaker';
$child_posts = toolset_get_related_posts(
$speaker_id, // get posts connected to this one
$relationship_slug, // in this relationship
array(
'query_by_role' => 'child', // origin post role
'role_to_return' => 'parent', // role of posts to return
'return' => 'post_object', // return array of IDs (post_id) or post objects (post_object)
'limit' => 999, // max number of results
'offset' => 0, // starting from
'orderby' => 'title',
'order' => 'ASC',
'need_found_rows' => false, // also return count of results
'args' => array(
'post_status' => 'publish',
),
)
);