Facebook Twitter Gplus RSS
Top Advantages of our payday loans Vitel Payday Where does the money go
formats

WordPress Using rewind_posts() to show multiple Custom Queries

Published on July 26, 2010, by in Wordpress.
I searched for a while on how to do this and finally think I figured it out but it still needs to be tweaked.
First you need to create your custom queries, I have created 2 here which pull from different categories.

I searched for a while on how to do this and finally think I figured it out but it still needs to be tweaked.
First you need to create your custom queries, I have created 2 here which pull from different categories.

<?php $my_query = new WP_Query('category_name=~Welcome~'); ?>

<?php $my_query2 = new WP_Query('category_name=~Site Updates~'); ?>

Replace

if (have_posts()) {while (have_posts()) {the_post();?>

With

if (have_posts()) {while ($my_query->have_posts()) {$my_query->the_post();?>

After the loop is finished (somewhere around the endif / or equivalent) Add

<?php rewind_posts(); ?>

Then copy and paste your entire loop but modify your initial query so it now reads your second custom query.

Related posts:

  1. WordPress – Show Posts from Specific Categories on HomepageThis post will explain the proceedure to show posts only from specifc or multiple categories on your WordPress home page. Enter the Admin section of your WordPress site then go to the Appearance => Editor =>. From the right select home.php (if it exists) or index.php (if home.php does not...
  2. WordPress wp_get_archives from specific category ?While trying to figure out how I could show posts from two categories but always keep one category on top I finally gave up. The best I could find was to run multiple custom queries using rewind_posts() but even this was difficult to carry from theme to theme as I...
  3. WordPress show Post Excerpts + ThumbnailsThis article will show you a couple methods for showing excerpts from posts on the homepage, for searches and for archives. First I will show you the manual method of editing the WordPress theme code to accomplish this but I urge you to read on as their is a much...
  4. WordPress create a custom Sidebar Posts QueryI have been trying to learn how to make my own custom WordPress sidebar widgets because every theme uses their own custom layout and I prefer a specific layout which I can only acomplish by manually editing the WordPress theme sidebar PHP file. In this post I will show you...
  5. WordPress Update Fatal error: Out of memory *FIX*So I was banging my head against the wall with this error and have upgraded my site manually the last couple times but this time I decided to dig a little into the error and see if I could finally resolve this. I found the normal articles about increasing the...
Home Articles Wordpress WordPress Using rewind_posts() to show multiple Custom Queries