Skip to content

Instantly share code, notes, and snippets.

@kaseybon
Last active September 20, 2019 16:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaseybon/7680189 to your computer and use it in GitHub Desktop.
Save kaseybon/7680189 to your computer and use it in GitHub Desktop.
Wordpress Mullet Loop: Place this loop in the index.php. Gives the option to pull in a custom content template for the most recent blog post in the blog feed e.g. Show full blog post for most recent post while only showing excerpts for older posts.
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<!-- Check for the first blog post in the loop && makes sure it the first page of results && makes sure it is the blog -->
<?php if ($count == 1 && $paged == 0 && is_home()) : ?>
<!-- Most recent blog post with custom template will display above older entries - Requires a content-featured.php or whatever you want to name your file or replace with code -->
<?php get_template_part( 'content', 'featured' ); ?>
<?php else : ?>
<!-- This will loop through the rest of the blog posts - Requires a content.php or replace with code -->
<?php get_template_part( 'content' ); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
<!-- Content that will display if no posts are available - Requires a content-none.php or replace with code -->
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment