Snippets

cutiko Wp Loop and Query

Created by cutiko

File template-something.php Added

  • Ignore whitespace
  • Hide word diff
+<!-- Basic WP loop -->
+<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
+<!-- Do what ever you want here -->
+<?php endwhile; endif; ?>
+
+<!-- WP Query for the recent posts -->
+<?php $recentpost = new WP_Query("showposts=6"); while($recentpost->have_posts()) : $recentpost->the_post(); ?>
+<!-- Do what ever you want here -->
+<?php endwhile; ?>
+
+<!-- WP Query for the recent custom posts (in this example the type is portfolio) -->
+<?php $recentPortfolio = new WP_Query( 'post_type=portfolio&posts_per_page=-1' ); while ($recentPortfolio->have_posts()) : $recentPortfolio->the_post(); ?>
+<!-- Do what ever you want here -->
+<?php endwhile; ?>
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.