Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//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>
// 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?:
// This will create a loop that shows 2 posts from the random category.
'category_name' => 'random-things',
'showposts' => '2',
)); ?>
// Add Previous and Next post links here. (
// Or just use the thematic action.
thematic_navigation_above(); ?>
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(); ?>
<!-- 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. (
// Or us the thematic action.
thematic_navigation_below(); ?>
// 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 ?>
<?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
You can’t perform that action at this time.