Skip to content

Instantly share code, notes, and snippets.

@goshdarnit
Created May 4, 2010 18:50
Show Gist options
  • Save goshdarnit/389800 to your computer and use it in GitHub Desktop.
Save goshdarnit/389800 to your computer and use it in GitHub Desktop.
<?php
function childtheme_index_loop(){
?>
<div id='column1'>
<?php
global $paged, $more;
$more = 0;
// Second, create a new temporary Variable for your query.
// $creative_query is the Variable used in this example query.
// If you run any new Queries, change the variable to something else more specific ie: $feature_wp_query.
$temp = $portfolio_query;
// Next, set your new Variable to NULL so it's empty.
$portfolio_query = null;
// Then, turn your variable int the WP_Query() function.
$portfolio_query = new WP_Query();
// Set you're query parameters. Need more Parameters?: http://codex.wordpress.org/Template_Tags/query_posts
$portfolio_query->query(array(
// This will create a loop that shows 2 posts from the creative category.
'category_name' => 'portfolio',
'posts_per_page' => 4,
)); ?>
<?php
$count = 1;
// While posts exists in the Query, display them.
while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?>
<?php // Start the looped content here. ?>
<div class="post">
<?php thematic_postheader(); ?>
<div class="entry-content">
<?php
the_content(); ?>
</div>
<?php thematic_postfooter(); ?>
</div> <!-- closes the first div box -->
<!--This is how to end a loop -->
<?php
/* In the case you're rendering the very last post, do nothing: */
if ($count == 9){
// Do nothing, thematic will add a '</div>' to close the last post
/* Is this the last post in the column?
That means if the loop number divides by 2 (or whatever post per column number we choose) */
/*If second colum*/
} elseif ($count%6 == 0){
/*If third column*/
/* if this is the bottom post, close the div and start a new div: */
echo '</div>
<div id="column3pg">';
} elseif ($count%3 == 0){
/*If third column*/
/* if this is the bottom post, close the div and start a new div: */
echo '</div>
<div id="column2pg">';
} else {
/* Do nothing, just move on, nothing to see here... */
}
/* We're about to finish the loop, let's add 1 to the count: */
$count = $count + 1;
endwhile; /* loop done, go back up */
/* All the posts are done, close the last column: */
echo '</div>';
?>
<?php
// End the Query and set it back to temporary so that it doesn't interfere with other queries.
$portfolio_query = null;
$portfolio_query = $temp;
}
//Add the function to the Action Hook.
add_action('thematic_belowcontainer','childtheme_index_loop');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment