Support » Themes and Templates » Need Help Debugging My Loop

  • Good afternoon,

    I am working on my 5th WordPress theme, and this time around I am going for a more advance layout style.

    The first posts shows in a full width column and ignores the more tag.

    The rest of the posts show in a 2 column grid with every two posts being wrapped in bootstraps row div.

    After googling these support forums, I find solutions for targeting the first post, ignoring the more tag and wrapping every 2 posts in a wrapper.

    I combined all 3 solutions together in a custom loop I have made, however it isn’t working. It causes the white screen of death including on every admin panel page and the only way to get access to the admin panel again is rename the theme folder.

    I know the basics of PHP but I’m no expert so I was hoping some one here could point out what I am doing wrong.

    Also, if you have any suggestions or better ways to accomplish the look I am going for I would greatly appreciate it.

    Here is my loop:

    <?php while ( have_posts() ) : the_post(); ?>
                    <article class="<?php post_class(); ?>" id="post-<?php the_ID(); ?>">
    	                <?php if( $wp_query->current_post == 0 && !is_paged() ) { /*first post*/ } ?>
    					<div id="article">
                        <aside class="featured_image tabel-cell">
                            <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                        </aside>
    
                        <aside>
                            <div class="section_text table-cell">
                            <h2>
    							<?php the_title(); ?>
    						</h2>
                        <?php global $more; $more = 1; the_content(); ?>
                        <p><a class="view-article" title="<?php printf( esc_attr__( 'Permalink to %s', 'compass' ), the_title_attribute( 'echo=0' ) ); ?>" href="<?php the_permalink(); ?>" rel="more"><em>read the full article</em></a></p>
                        </div><!-- section_text -->
                        </aside>
                    </div><!-- #section -->
                </article>
                    <?php else : ?>
                    	<?php if( $wp_query->current_post%2 == 1) echo "\n".'<div class="row">'."\n";
                  } else {
                    if( $wp_query->current_post%2 !== 1) echo "\n".'<div class="row">'."\n";
                  }
                  ?>
                    	<div class="row">
                    <div class="col-xs-6">
                        <article class="<?php post_class(); ?>" id="post-<?php the_ID(); ?>">
                            <div id="article_recent">
                                <aside class="featured_image_small tabel-cell">
                                    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                                </aside>
    
                                <div class="table-cell">
                                    <h4><?php the_title(); ?></h4>
    
                                  <?php global $more; $more = 0; the_content('[Read more...]'); ?>
    
                                    <p><a class="view-article" title="<?php printf( esc_attr__( 'Permalink to %s', 'compass' ), the_title_attribute( 'echo=0' ) ); ?>" href="<?php the_permalink(); ?>" rel="more"><em>read the full article</em></a></p>
                                </div><!-- section_text -->
                            </div><!-- #section -->
                        </article>
                        <?php
                        if( $wp_query->current_post%2 == 0 || $wp_query->current_post == $wp_query->post_count-1 ) echo '</div> <!--/.wrap-->'."\n";
      } else {
        if( $wp_query->current_post%2 !== 0 || $wp_query->current_post == $wp_query->post_count-1 ) echo '</div> <!--/.wrap-->'."\n";
      }
      ?>
                    </div>
    
                    <?php endif ?>
    
                    <?php endwhile; ?>

    Thank you=)

  • The topic ‘Need Help Debugging My Loop’ is closed to new replies.