Loop with break in the middle

Try using a loopcounter based on the post number count – provides for more flexibility <?php if (have_posts()) : ?> <?php $count = 0; ?> <?php while (have_posts()) : the_post(); ?> <?php $count++; ?> // if you are in your first post <?php if ($count == 1) : ?> // do whatever you want to … Read more

WordPress search exact match

You might want to append the query parameter sentence=1 in your search, it is not well documented, but it should retrieve content inside the post that matches exactly the sentence pattern. Alternatively, for a more powerful search, you might want to give a look at Relevanssi plugin. A lot of people agree that WordPress search … Read more

Loop inside the loop

I would use get_posts() for your two ad hoc Loops. (Actually, you only need one ad hoc Loop, if you’re modifying the main Loop so that only 2 posts are retrieved.) e.g. \\ code modify main Loop to return only 2 posts goes here $firstpost = true; if ( have_posts() ) : while ( have_posts() … Read more