Hi all,
Sorry I didn't know where to place this topic, because could resolve around a number of matters, but it comes down to a wordpress help I need, maybe we should create a wordpress, or any other CMS forum? this would be handy.
Anyway back on topic, I want an archives page to look similar to this:
http://veerle.duoh.com/blog/archives/
Yes, I am aware that this isn't used for wordpress, but I still want this affect, so I have install a plugin and created my archives page, but I don't know where in the
PHP I can edit to change it to add a little javascript to get a similar affect. It doesn't have to be complicated, just with a basic tab system would do. Below is my code that I have so far, and I will attach a screenshot of the page so far, so could someone please advise where? and how to add this affect?
- PHP: Select all
<?php
/*
Plugin Name: Smart Archives
Version: 1.9.2
Plugin URI: http://justinblanton.com/projects/smartarchives/
Description: A simple, clean, and future-proof way to present your archives.
Author: Justin Blanton
Author URI: http://justinblanton.com
*/
function smartArchives($format='both', $catID='') {
global $wpdb, $PHP_SELF;
setlocale(LC_ALL,WPLANG); // set localization language
$now = gmdate("Y-m-d H:i:s",(time()+((get_settings('gmt_offset'))*3600))); // get the current GMT date
$bogusDate = "/01/2001"; // used for the strtotime() function below
$yearsWithPosts = $wpdb->get_results("
SELECT distinct year(post_date) AS `year`, count(ID) as posts
FROM $wpdb->posts
WHERE post_type = 'post'
AND post_status = 'publish'
GROUP BY year(post_date)
ORDER BY post_date DESC");
foreach ($yearsWithPosts as $currentYear) {
for ($currentMonth = 1; $currentMonth <= 12; $currentMonth++) {
$monthsWithPosts[$currentYear->year][$currentMonth] = $wpdb->get_results("
SELECT ID, post_title FROM $wpdb->posts
WHERE post_type = 'post'
AND post_status = 'publish'
AND year(post_date) = '$currentYear->year'
AND month(post_date) = '$currentMonth'
ORDER BY post_date DESC");
}
}
if (($format == 'both') || ($format == 'block')) { // check to see if we are supposed to display the block
// get the shortened month name; strftime() should localize
for($currentMonth = 1; $currentMonth <= 12; $currentMonth++) $shortMonths[$currentMonth] = ucfirst(strftime("%b", strtotime("$currentMonth"."$bogusDate")));
if ($yearsWithPosts) {
foreach ($yearsWithPosts as $currentYear) {
for ($currentMonth = 1; $currentMonth <= 12; $currentMonth++) {
if ($monthsWithPosts[$currentYear->year][$currentMonth]) echo ('<a href="'.get_month_link($currentYear->year, $currentMonth).'" class="another_month">'.$shortMonths[$currentMonth].'</a> ');
else echo '<span class="emptymonth">'.$shortMonths[$currentMonth].'</span> ';
}
echo '<br/>';
}
echo '<br /><br />';
}
}
if (($format == 'both') || ($format == 'list')) { //check to see if we are supposed to display the list
// get the month name; strftime() should localize
for($currentMonth = 1; $currentMonth <= 12; $currentMonth++) $monthNames[$currentMonth] = ucfirst(strftime("%B", strtotime("$currentMonth"."$bogusDate")));
if ($yearsWithPosts) {
if ($catID != '') { // at least one category was specified to be excluded
$catIDs = explode(" ", $catID); // put the category(ies) into an array
foreach($yearsWithPosts as $currentYear) {
for ($currentMonth = 12; $currentMonth >= 1; $currentMonth--) {
if ($monthsWithPosts[$currentYear->year][$currentMonth]) {
echo ('<h2><a href="'.get_month_link($currentYear->year, $currentMonth).'">'.$monthNames[$currentMonth].' '.$currentYear->year.'</a></h2>');
echo '<ul>';
foreach ($monthsWithPosts[$currentYear->year][$currentMonth] as $post) {
if ($post->post_date <= $now) {
$cats = wp_get_post_categories($post->ID);
$found = false;
foreach ($cats as $cat) if (in_array($cat, $catIDs)) $found = true;
if (!$found) echo ('<li><a href="'.get_permalink($post->ID).'class="theselinks">'.$post->post_title.'</a></li>');
}
}
echo '</ul>';
}
}
}
}
else { // we don't need to exclude any categories
foreach($yearsWithPosts as $currentYear) {
for ($currentMonth = 12; $currentMonth >= 1; $currentMonth--) {
if ($monthsWithPosts[$currentYear->year][$currentMonth]) {
echo ('<h2><a href="'.get_month_link($currentYear->year, $currentMonth).'class="theselinks">'.$monthNames[$currentMonth].' '.$currentYear->year.'</a></h2>');
echo '<ul>';
foreach ($monthsWithPosts[$currentYear->year][$currentMonth] as $post) echo ('<li><a href="'.get_permalink($post->ID).'class="theselinks">'.$post->post_title.'</a></li>');
echo '</ul>';
}
}
}
}
}
}
} ?>
Thanks for your help
Craig
