• Hello,

    I have written a WP query and I have a problem for display ordering images in attachment to the article. If I change the order of the images in the backoffice with the Download Attachments plugin, this sort is not displayed on the frontoffice page.

    I must be mistaken in the call of the parameter “menu_order”, we must probably put something else.

    Could anyone help me to modify this code below and allow me to see frontoffice my ranking done in backoffice?

    Thank you very much for your help.

    t.

    $thumb_ID = get_post_thumbnail_id( $post->ID );
        $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_parent' => $post->ID, 'post__not_in' => array( $thumb_ID ), 'orderby' => 'menu_order', 'order' => 'ASC', );
        $attachments = get_posts( $args );
        if ( $attachments ) {
           
     foreach ( $attachments as $attachment ) {
                $image_attributes = wp_get_attachment_image_src( $attachment->ID, '' );
                $image_vignettes = wp_get_attachment_image_src( $attachment->ID, 'vignette' );
                echo '<div class="grid-item"><a href="';
                echo $image_attributes[0];
                echo '">';
                echo '<img src="ui/i/blank.gif" alt="" data-echo="'.$image_vignettes[0].'" width="'.$image_vignettes[1].'" height="'.$image_vignettes[2].'" >';
                echo '</a></div>';  
    	}
  • The topic ‘WP Query and menu order’ is closed to new replies.