<?php
/* Template Name: Archive */
get_header(); ?>
<div id="insidebanner">
<?php if(get_post_meta($post->ID, 'banner_image', true)) { ?><p><img src="<?php echo get_post_meta($post->ID, 'banner_image', true); ?>" alt="" /></p><?php } ?>
<h2><?php the_title(); ?></h2>
<?php if(get_post_meta($post->ID, 'banner_text', true)) { ?><p class="tagline"><?php echo stripslashes(get_post_meta($post->ID, 'banner_text', true)); ?></p><?php } ?>
</div><!-- end banner -->
<div id="mainarea">
<div id="contentarea" class="fullwidth archive">
<?php
/*
Plugin Name: favrik Recent Posts
Plugin URI: http://blog.favrik.com/
Description: Display recent posts by date: 1) grouping by year, month,day, and 2) just the date at the left side of the title. Based on the work by <a href="http://www.ardamis.com">Oliver Baty</a>. <a href=" http://www.ardamis.com/2007/06/25/adding-the-post-date-to-wp_get_archives/">Details are here</a>.
Version: 0.1
Author: Favio Manriquez
Author URI: http://blog.favrik.com
Copyright 2007 Favio Manriquez (email : favio@favrik.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Most important configuration variable is $group:
0 - Just put the date at the left side.
1 - Group by year, month, and day.
*/
function favrik_recent_posts($args = '') {
global $wp_locale, $wpdb;
// params fun
parse_str($args, $r);
$defaults = array('group' => '1', 'limit' => '10', 'before' => '<li>', 'after' => '</li>', 'show_post_count' => false, 'show_post_date' => true, 'date' => 'F jS, Y', 'order_by' => 'post_date DESC');
$r = array_merge($defaults, $r);
extract($r);
// output
$output = '';
$pre = '';
$full_date = '';
$year = '';
$month = '';
$day = '';
// the query
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'");
$join = apply_filters('getarchives_join', "");
$qry = "SELECT ID, post_date, post_title, post_name
FROM $wpdb->posts $join
$where ORDER BY $order_by LIMIT $limit";
$arcresults = $wpdb->get_results($qry);
if ($arcresults) {
foreach ($arcresults as $arcresult) {
if ($arcresult->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult);
if ($group == 0) { // dates at the side of the post link
$arc_date = date($date, strtotime($arcresult->post_date));
$full_date = '<em class="date">' . $arc_date . '</em> ';
}
if ($group == 1) { // grouping by year then month-day
$m = date('F Y', strtotime($arcresult->post_date));
$y = date('Y', strtotime($arcresult->post_date));
if ($month != $m) {
$month = $m;
$pre .= '</div><div class="archivebox"><h2 class="archivemonth">' . substr($month, 0, -4) . $y.'</h2>';
}
$d = date('jS', strtotime($arcresult->post_date));
if ($day != $d) {
$day = $d;
$full_date = '<em>' . $day . '</em>';
}
}
if(has_category('fbknews', $arcresults)) {
$output .= $pre;
$output .= get_the_archive_post($arcresult->ID);
$pre = ''; $full_date = '';
}
}
}
}
echo $output;
}
function get_the_archive_post($id) {
query_posts('p='.$id); while ( have_posts() ) : the_post();
if(get_option('use_thumb_script') == "No") { $thumbscript = 'width="184" height="auto"'; }
$post .= '<div class="post"><div class="overlay"></div><div class="entry">
<p><a href="'.get_permalink().'"><img src="'.get_thumbnail($id, '184', '120').'" alt="" '.$thumbscript.'/></a></p>
<h3><a href="'.get_permalink().'">'.get_the_title().'</a></h3>
<p>'.smallerexcerptreturn(24).'</p></div></div>';
return $post;
endwhile; wp_reset_query();
}
?>
<div>
<?php favrik_recent_posts('group=0&limit=1000'); ?>
</div>
</div><!-- end content area -->
<?php get_footer(); ?>