create pagination post with meta post image value

2019-07-25 02:16发布

i have gallery post , with value post is image from meta post , and i want make this post like this fiddle but i dont know how to make it , i was try use this code

<?php 
while ( have_posts() ) : the_post();
global $post;
$val = get_post_meta($post->ID,'value_gallery',false);
$args = array(
    'posts_per_page' => 6,
    'order'          => 'ASC',
    'post_mime_type' => 'image',
    // 'post_parent'    => the_ID(),
);

$attachments = get_children( $args );

if ( $attachments ) {
        foreach ($val as $key ) {
        $keys = explode(",", $key);
        foreach ($keys as $values) {
            ?>
     <div class="col-lg-4">
        <?php echo wp_get_attachment_image( $values,  "cherry-thumb-a", array( "class" => "img-responsive" ) );  ?>
     </div>
            <?php
        }
    }
}
?>
<!-- pagination -->
<div class="nav-pagination">
<?php the_posts_pagination( array(
'mid_size'  => 2,
'prev_text' => __( '<', 'textdomain' ),
'next_text' => __( '>', 'textdomain' ),) );
 ?>
 </div>

but the nav for pagination not show , and item for display still display all not show 6 per page , i will happy if anyone can help me

0条回答
登录 后发表回答