Well, I’m just trying to test out the new features being added to WordPress by using them on my blog.
- The first new thing is the ability to post to multiple categories.
- The second new thing is my hack which enables announcement posts which always show (you do it by creating a category, and the most recent post in that category would be visible, using this hack, wherever you want).
- The third thing is another hack visible on that same page … the ability to have the most recent X posts displayed in a list (look in the side-bar of that page).
Well, both of those hacks are pretty simple, so I figure I’ll share them with the world.
For the first, all you have to do is create a page with just the post portion of your index page (edit it to suit) and include it using a full http url. The only trick is that you probably only want to include it on the front page, so you should check to make sure, like so:
<?php if( '' == $cat && '' == $p ) { include('http://www.huddledmasses.org/wp-includes/announce.php'); } ?>
For the second, you have to hack your template functions file … the get_archives() needs an extra parameter to allow us to pass in a category id … it’s simple, just edit three spots. Feel free to just copy my hacked version, but beware that it’s from the latest CVS version. If you want to edit yours instead, here’s the instructions:
- first line: the definition of the function (around line 127 of template_functions.php) should read: '', $limit='', $format='html', $before = '', $after = '', $show_post_count=false, $category='') {
- second line: just below that, above the line that reads if (’‘ != $limit) {, paste this (the ‘’ in the first line is two single quotes): if ('' != $category) { $category = "AND post_category = '$category' "; }
- third line: the get_results call in the “postbypost” section (around line 212 of template_functions.php) must be: $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts"
." WHERE post_date < '$now' AND post_status = 'publish' " . $category
." ORDER BY post_date DESC" . $limit);
That’s it. Now just add a function call where you want the index. the second parameter is the number of links you want, the last parameter is the number of the category you want the links from (in this case, 7).
2 Comments
Jaykul,
I’m looking forward to learning about your hacks! Thanks for sharing…however, you need to change two of your links in this post to .ORG instead of .COM!
Have a great day! See you around the WP forums.
well it seems they merged this into CVS