Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get this overly complicated loop to work correctly
    primarykey
    data
    text
    <p>So I'm editing the index.php in my WP theme's folder, essentially what I want it to do is this:</p> <ul> <li><p>Show 4 Posts on first page of blog.</p></li> <li><p>Style the first (newest) post on the first page differently. Style the other 3 the same.</p></li> <li><p>Show 6 Posts on every other paginated page.</p></li> </ul> <p>Here's the loop I'm working with, the first page appears fine, but for some reason on page 2 and higher it's executing really weird and showing only <strong>one</strong> post on each additional page. Also, it will only show the title and not the date or excerpt. Here's my code:</p> <pre><code> &lt;?php if( is_home() &amp;&amp; !is_paged() ){ global $query_string; parse_str( $query_string, $args ); $args['posts_per_page'] = 4; query_posts($args); if (have_posts()) : while (have_posts()) : the_post(); if (++$counter == 1) { ?&gt; &lt;div class="featured_post"&gt; &lt;p class="date"&gt;&lt;?php the_date('M j, Y'); ?&gt;&lt;/p&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;&lt;/a&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_post_thumbnail('featuredblog'); ?&gt;&lt;/a&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt; &lt;?php } else { ?&gt; &lt;div class="regular_post"&gt; &lt;p class="date"&gt;&lt;?php the_date('M j, Y'); ?&gt;&lt;/p&gt; &lt;div class="postimage"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_post_thumbnail('regularblog'); ?&gt;&lt;/a&gt;&lt;/div&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;h3&gt;&lt;?php // short_title($after, $length) echo short_title('...', 7); ?&gt;&lt;/h3&gt;&lt;/a&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;?php endwhile; else : // Code for no posts found here endif; } else { global $query_string; parse_str( $query_string, $args ); $args['posts_per_page'] = 6; query_posts($args); ?&gt; &lt;div class="regular_post"&gt; &lt;p class="date"&gt;&lt;?php the_date('M j, Y'); ?&gt;&lt;/p&gt; &lt;div class="postimage"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_post_thumbnail('regularblog'); ?&gt;&lt;/a&gt;&lt;/div&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;&lt;/a&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre> <p>Maybe there's too many if...else statements in there?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload