I am trying to make a page that displays a Custom Post Type.
I need for all post to be displayed twice. Once at a list of products and once as a modal. I am able to display the product list on the page but I can't get the second post query for the modals to work.
Products page:
<div>
<main>
<?php
if ( have_posts() ) : ?>
<header class="page-header">
<?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
the_archive_description( '<div class="archive-description">', '</div>' );
?>
</header> <!-- .page-header -->
<?php
/* Start the Loop */
$args = array( 'post_type' => 'kollektion' );
$loop = new WP_Query( $args );
if( $loop ->have_posts() ) :
while( $loop->have_posts() ) : $loop->the_post();
get_template_part( 'template-parts/content-kollektion', get_post_format() );
endwhile;
endif;
the_posts_navigation();
else :
get_template_part( 'template-parts/content-kollektion', 'none' );
endif;
wp_reset_postdata();
?>
</main> <!-- #main -->
</div> <!-- #primary -->
<!-- modal Kollektion 02 -->
<div class="modalDialog">
<section class="kollektion-slider">
<?php
rewind_posts();
/* Start the Loop */
$args = array( 'post_type' => 'kollektion' );
$loop = new WP_Query( $args );
if( $loop ->have_posts() ) :
while( $loop->have_posts() ) :
$loop->the_post();
get_template_part( 'template-parts/content-kollektion-modal', get_post_format() );
endwhile;
endif;
wp_reset_postdata();
?>
</section>
</div>
content-kollektion-modal.php
:
<div id="post-modal<?php the_ID(); ?>">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Modal Box</h2>
<img src="<?php the_field('image_collection'); ?>" />
</div>
</div>
rewind_posts()
with a custom query? codex.wordpress.org/Function_Reference/… – Michael Sep 27 '16 at 23:03