Recent Posts by Category and Recent Comments
-
Hey,
I’m looking for a way to trim a few hours off my workload π
I know i have seen in the past someone who has hacked the categories list to also include a list of recent posts per-category eg:
Category 1
Category 1 Post 1
Category 1 Post 2
Category 1 Post 3
Category 2
Category 2 Post 1
Category 2 Post 2
Category 2 Post 3And so on until the categories(or cows) come home. For a more visual example, visit: http://www.brandontennant.com/blog_screen.png
Any suggestions would be appreciated.
Thanks,
Brandon
-
I was grappling with a similar issue on my site, and I came across some code on this forum (I can’t remember exactly where I found it or I’d post a link) that lets you do something like that. Try this, replacing CAT_ID with the appropriate numeric category ID:
<?php
$temp_query = $wp_query;
$catposts = ‘cat=CAT_ID&paged=1&order=DESC’;
query_posts($catposts);
while (have_posts()) : the_post();
echo ‘<a href=”‘;
the_permalink();
echo ‘”>’;
the_title();
echo “”;
endwhile;
$wp_query = $temp_query;
?>This code only lists recent posts belonging to a single, specified category, which may not be exactly what you want. However, you could put it in a function and call that function repeatedly.
CG-SameCat does basically what ebonmuse outlined — it pulls up a list of posts from a given category. But, it can give both temporal or random results.
Certainly the best approach is a foreach over the categories list, and a call to samecat (or your own function) that retrieves a list of posts for that category.
-d
Hey Guys, thanks for the replies.
For the blog I’ve used a hack solution, it’s not dynamic so it isn’t portable which is a big negative because we are going to roll this blog out across all the chapters of our group. You can see what i currently have online at http://bc.gdc.net/blogI used a plugin called wp_cat_posts() to pull the most recent entries but it is somewhat limited. Below is the code for my left hand column, if anyone has suggestions on how to code this in a better way, please let me know…
<div class="masthead">categories</div>
<div class="category_group">
<form id="catform" action="">
<select name="archive_chrono" onchange="window.location=(document.forms.catform.archive_chrono[document.forms.catform.archive_chrono.selectedIndex].value);">
<option value=''>Select category</option>
<?php zelig_dropdown_cats(); ?>
</select></form>
</div><div class="masthead">associations</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(10); ?>
</ul>
</div>
<div class="masthead">branding</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(8); ?>
</ul>
</div>
<div class="masthead">ecommunications</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(11); ?>
</ul>
</div>
<div class="masthead">education</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(2); ?>
</ul>
</div>
<div class="masthead">ethics & practices</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(5); ?>
</ul>
</div>
<div class="masthead">events</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(3); ?>
</ul>
</div>
<div class="masthead">graphex</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(12); ?>
</ul>
</div>
<div class="masthead">membership</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(6); ?>
</ul>
</div>
<div class="masthead">miscellaneous</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(9); ?>
</ul>
</div>
<div class="masthead">sponsorship</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(7); ?>
</ul>
</div>
<div class="masthead">students</div>
<div class="category_group">
<ul>
<?php wp_cat_posts(4); ?>
</ul>
</div><div class="masthead">archives</div>
<div class="category_group">
<form id="archiveform" action="">
<select name="archive_chrono" onchange="window.location =(document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">
<option value=''>Select Month</option>
<?php get_archives('monthly','','option'); ?>
</select>
</form>
</div>
The topic ‘Recent Posts by Category and Recent Comments’ is closed to new replies.