Miniblog is another variant of Asides. This application of Loop set aside all Posts of a specific category in a space separate from the rest of the Posts. This aggregation of Posts commonly resides in the sidebar.
<?php get_header(); ?>
<div id="mainContent">
<?php $wp_query->set( 'cat', '-6' ); ?>
<?php query_posts( '' ); ?>
<?php if( have_posts() ) : ?>
<?php while( have_posts() ) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="meta"><?php the_category( ', ' ); ?> <?php the_author(); ?> <?php the_time('F jS, Y'); ?></div>
<div class="entry">
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<div class="error">
<h2>Not Found</h2>
<p>Sorry, but you are looking for something that isn't here.</p>
<?php include( TEMPLATEPATH . '/searchform.php' ); ?>
</div>
<?php endif; ?>
</div>
<div id="sideContent">
<?php query_posts( 'category_name=Inline Function&showposts=10' ); ?>
<?php if( have_posts() ) : ?>
<h2>Inline Function</h2>
<ul>
<?php while( have_posts() ) : the_post(); ?>
<li id="post-<?php the_ID(); ?>"><?php echo wptexturize( $post->post_content ); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Just like Asides, Miniblog implementation requires the reservation of a category. However, unlike Asides, Miniblog requires two Loops to make it happen.
Line 5
of the code above set the variable $wp_query
, which contains the information about the Posts to be displayed and is accessed heavily by the Loop, to have a query variable cat
of -6 (minus six).
Pingback: Rhymed Code » Feature
Hmmm… I seem to get errors on line 5 and 36. The minus before the category ID seemed to cause a T STRING error, and I don’t remember what the other error said.
I’m very sure I didn’t misspell anything, it was just copied and pasted and only the number and category name changed. Any idea what can be the problem?
Thank you.
Re-type all the quote symbols (‘).
Ah, right. Now I feel stupid.
Thanks a lot!
I wonder if separate paginations are possible for each loop. At the moment i do have 2 loops with different categories displayed, and the main loop. But pagination for the main loop is screwed up …
Great reading, keep up the great posts.
Peace, JiggaDigga