ご覧のとおり、ギャラリーを希望の順序で並べ替えるのに苦労しています。ギャラリーを編集するドラッグ アンド ドロップ インターフェイスと同じように並べ替えようとしています。これは、ショートコードの id 属性と同じ順序です。$orderby に割り当てる値がわかりません。「ID」、「menu_order」、および「post__in」を試しましたが、変更はありません。何かアドバイスはありますか。
add_filter('post_gallery', 'fgf_gallery', 10, 2);
function fgf_gallery($output, $attr) {
global $post;
static $instance = 0;
$instance++;
$id = $post->ID;
$order = 'ASC';
$orderby = 'ID';
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
if ( empty($attachments) ) return;
$output = "<ul id='gallery-{$instance}' class='gallery'>";
foreach ( $attachments as $id => $attachment ) {
$output .= "<li class='gallery-item'>";
$output .= "<img src='".$thumb_src."'>";
$output .= "<h1>".$attachment->post_title."</h1>";
if ( trim($attachment->post_excerpt) ) {
$output .= "
<p class='wp-caption-text gallery-caption'>
" . wptexturize($attachment->post_excerpt) . "
<p>";
}
$output .= "</li>";
}
$output .= "</ul>\n";
return $output;
}
ありがとう。さらなるドキュメントへのヒントもありがたかったです。