2017-09-08 2 views
0
function my_relationship_query($args, $field, $post_id) { 

// only show children of the current post being edited 
$args['post_parent'] = $post_id; 


// return 
return $args; 

} IchWP, mehrere IDs übergeben

Wie zum Beispiel die Abfrage zwei Parameter als post_id passieren könnte? Ist der einzige Weg das zu tun, das Schreiben einiger Meta-Anfragen?

Antwort

1

eine Reihe von post-IDs Geben zu post_parent__in pro WP_Query (unter der Annahme $args ist repräsentativ für WP_Query params):

$post_id_array = array($id1,$id2); 

function my_relationship_query($args, $field, $post_id_array) { 

// only show children of the current post being edited 
$args['post_parent__in'] = $post_id_array; 


// return 
return $args; 
+0

Hm, Nr. funktioniert nicht so. – revengeance