twodinks.com

Feature Box with single post from designated category

by on Aug.19, 2010, under Snippets

Sometimes you need to throw something up front and center for all the world to see. Leave your pants on, Mazz, I’m talking about blog posts.

/* populates feature box with latest post excerpt :: change category name to taste*/

function featurecontent() { ?>

<div id=”my-feature-box”>

// start loop with query for specific category of post & desired number to display
<?php $my_query = new WP_Query(‘category_name=video&showposts=1′); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?>

// set title of displayed post to display as h2 and supply permalink to full article
<h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h2>

// display the content or change to the_excerpt if desired
<?php the_content(); ?>

// offer link to the rest of the article if using an excerpt
<div class=”featurereadmore”>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Read the full article”>Read the full article &rarr;</a>
</div>

// end the loop
<?php endwhile; ?>
</div>
<?php
}

add_action(‘thesis_hook_feature_box’, ‘featurecontent’);


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!