Skip to content

Instantly share code, notes, and snippets.

@mushon
Created April 27, 2010 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mushon/381058 to your computer and use it in GitHub Desktop.
Save mushon/381058 to your computer and use it in GitHub Desktop.
<?php
//Column 3: Create a function and div to hold all random category posts
function random_category_loop(){
if (is_home() & !is_paged()) { ?>
<div id="randomcategory" class="category span-14 last floatright">
<!-- Use html to create category titles -->
<div class="categoryheader">
<div id="randomthingscategory" class="floatright span-14 last categorytitle">
<p><a href="http://localhost:8888/blog/category/random/">RANDOM <br>THINGS I LIKE</p>
</div>
</div>
<?php
// Create another query for the random things category.
global $paged, $more;
$more = 0;
$temp = $random_query;
$random_query = null;
$random_query = new WP_Query();
// Set your query parameters. Need more Parameters?: http://codex.wordpress.org/Template_Tags/query_posts
$random_query->query(array(
// This will create a loop that shows 2 posts from the random category.
'category_name' => 'random-things',
'showposts' => '2',
)); ?>
<?php
// Add Previous and Next post links here. (http://codex.wordpress.org/Template_Tags/previous_post_link)
// Or just use the thematic action.
thematic_navigation_above(); ?>
<?php
while ($random_query->have_posts()) : $random_query->the_post(); ?>
<?php // Start the looped content here. ?>
<div class="post">
<!-- Display the Title as a link to the Post's permalink. -->
<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<!-- Display the date (November 16th, 2009 format) and the tags. -->
<div class = "metadata"><small>Posted on <?php the_time('F jS, Y') ?> with <?php if ( comments_open() ) : ?><?php comments_popup_link( 'no reading material', '1 inspired person', '% inspired people', 'comments-link', 'Comments are off for this post'); ?><?php endif; ?>.<?php the_tags(' Filed under ', ', '); ?>.</small></div>
</div> <!-- closes the first div box -->
<!--This is how to end a loop -->
<?php endwhile;
// Add Previous and Next post links here. (http://codex.wordpress.org/Template_Tags/previous_post_link)
// Or us the thematic action.
thematic_navigation_below(); ?>
<?php
// End the Query and set it back to temporary so that it doesn't interfere with other queries.
$random_query = null; $random_query = $temp; ?>
<?php // End of random query ?>
</div>
</div>
<?php }
}
// And in the end activate the new loop.
add_action('thematic_abovecontainer', 'random_category_loop');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment