Need 2 blog pages in theme with custom loop on second page
-
I have a website that needs 2 blog pages. I found this code that does the trick:
<?php // the query $wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?> <?php if ( $wpb_all_query->have_posts() ) : ?> <ul> <!-- the loop --> <?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <!-- end of the loop --> </ul> <?php wp_reset_postdata(); ?> <?php else : ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?>
But I need it to be identical to the way the code works on my index.php. Here is the code for that:
<?php while (have_posts()): the_post() ?> <?php if ($wp_query->current_post % 2 == 0): ?> <?php if(!has_post_thumbnail() || get_theme_mod( 'md_post_thumb_all')) : $no_featured_img_list = "no_featured_img_list"; endif; ?> <article> <div class="section group"> <div class="col span_1_of_2"> <?php if(has_post_thumbnail() && !get_theme_mod( 'md_post_thumb_all')) : ?> <div class="post-img"> <a href="<?php echo get_permalink() ?>"><?php the_post_thumbnail('mini-thumb'); ?></a> </div> <?php endif; ?> </div> <div class="col span_1_of_2"> <div class="blogcontent"> <h2><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> <br> <a href="<?php echo get_permalink(); ?>" class="readmore">READ MORE</a> </div> </div> </div> </article> <?php else: ?> <?php if(!has_post_thumbnail() || get_theme_mod( 'md_post_thumb_all')) : $no_featured_img_list = "no_featured_img_list"; endif; ?> <article> <div class="section group"> <div class="col span_1_of_2"> <div class="blogcontent"> <h2><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> <br> <a href="<?php echo get_permalink(); ?>" class="readmore">READ MORE</a> </div> </div> <div class="col span_1_of_2"> <?php if(has_post_thumbnail() && !get_theme_mod( 'md_post_thumb_all')) : ?> <div class="post-img2"> <a href="<?php echo get_permalink() ?>"><?php the_post_thumbnail('mini-thumb'); ?></a> </div> <?php endif; ?> </div> </div> </article> <?php endif ?> <?php endwhile ?>
Can someone help me? I’m having trouble wrapping my head around what that would look like. Thank you in advance!
- The topic ‘Need 2 blog pages in theme with custom loop on second page’ is closed to new replies.