Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Wordpress Help With Archives
This is a discussion on Wordpress Help With Archives, within the Web Development in General section. This forum and the thread "Wordpress Help With Archives" are both part of the Programming Your Website category.
![]() ![]() |
Jun 19 2008, 04:47 AM
Post
#1
|
|
|
Squeezing ![]() ![]() ![]() Group: Members Posts: 65 Joined: 13-March 08 Member No.: 200 |
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? CODE [font="Tahoma"]<?php [/font][font="Tahoma"]/* 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=''[/font][font="Tahoma"]) { global $wpdb, $PHP_SELF[/font][font="Tahoma"]; setlocale(LC_ALL,WPLANG); [/font][font="Tahoma"]// set localization language $now = gmdate("Y-m-d H:i:s",(time()+((get_settings('gmt_offset'))*3600))); [/font][font="Tahoma"]// get the current GMT date $bogusDate = "/01/2001"; [/font][font="Tahoma"]// used for the strtotime() function below $yearsWithPosts = $wpdb->get_results([/font][font="Tahoma"]" 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"[/font][font="Tahoma"]); foreach ($yearsWithPosts as $currentYear[/font][font="Tahoma"]) { for ($currentMonth = 1; $currentMonth <= 12; $currentMonth[/font][font="Tahoma"]++) { $monthsWithPosts[$currentYear->year][$currentMonth] = $wpdb->get_results([/font][font="Tahoma"]" 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"[/font][font="Tahoma"]); } } if (($format == 'both') || ($format == 'block')) { [/font][font="Tahoma"]// 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"[/font][font="Tahoma"]))); if ($yearsWithPosts[/font][font="Tahoma"]) { foreach ($yearsWithPosts as $currentYear[/font][font="Tahoma"]) { for ($currentMonth = 1; $currentMonth <= 12; $currentMonth[/font][font="Tahoma"]++) { if ($monthsWithPosts[$currentYear->year][$currentMonth]) echo ('<a href="'.get_month_link($currentYear->year, $currentMonth).'" class="another_month">'.$shortMonths[$currentMonth].'</a> '[/font][font="Tahoma"]); else echo '<span class="emptymonth">'.$shortMonths[$currentMonth].'</span> '[/font][font="Tahoma"]; } echo '<br/>'[/font][font="Tahoma"]; } echo '<br /><br />'[/font][font="Tahoma"]; } } if (($format == 'both') || ($format == 'list')) { [/font][font="Tahoma"]//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"[/font][font="Tahoma"]))); if ($yearsWithPosts[/font][font="Tahoma"]) { if ($catID != '') { [/font][font="Tahoma"]// at least one category was specified to be excluded $catIDs = explode(" ", $catID); [/font][font="Tahoma"]// put the category(ies) into an array foreach($yearsWithPosts as $currentYear[/font][font="Tahoma"]) { for ($currentMonth = 12; $currentMonth >= 1; $currentMonth[/font][font="Tahoma"]--) { if ($monthsWithPosts[$currentYear->year][$currentMonth[/font][font="Tahoma"]]) { echo ('<h2><a href="'.get_month_link($currentYear->year, $currentMonth).'">'.$monthNames[$currentMonth].' '.$currentYear->year.'</a></h2>'[/font][font="Tahoma"]); echo '<ul>'[/font][font="Tahoma"]; foreach ($monthsWithPosts[$currentYear->year][$currentMonth] as $post[/font][font="Tahoma"]) { if ($post->post_date <= $now[/font][font="Tahoma"]) { $cats = wp_get_post_categories($post->ID[/font][font="Tahoma"]); $found = false[/font][font="Tahoma"]; foreach ($cats as $cat) if (in_array($cat, $catIDs)) $found = true[/font][font="Tahoma"]; if (!$found) echo ('<li><a href="'.get_permalink($post->ID).'class="theselinks">'.$post->post_title.'</a></li>'[/font][font="Tahoma"]); } } echo '</ul>'[/font][font="Tahoma"]; } } } } else { [/font][font="Tahoma"]// we don't need to exclude any categories foreach($yearsWithPosts as $currentYear[/font][font="Tahoma"]) { for ($currentMonth = 12; $currentMonth >= 1; $currentMonth[/font][font="Tahoma"]--) { if ($monthsWithPosts[$currentYear->year][$currentMonth[/font][font="Tahoma"]]) { echo ('<h2><a href="'.get_month_link($currentYear->year, $currentMonth).'class="theselinks">'.$monthNames[$currentMonth].' '.$currentYear->year.'</a></h2>'[/font][font="Tahoma"]); echo '<ul>'[/font][font="Tahoma"]; foreach ($monthsWithPosts[$currentYear->year][$currentMonth] as $post) echo ('<li><a href="'.get_permalink($post->ID).'class="theselinks">'.$post->post_title.'</a></li>'[/font][font="Tahoma"]); echo '</ul>'[/font][font="Tahoma"]; } } } } } } } ?> [/font] Thanks for your help Craig
Attached File(s)
|
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
5 | karinne | 292 | 25th March 2008 - 08:07 AM Last post by: karinne |
|||
![]() |
0 | Ryan | 217 | 7th March 2008 - 07:39 AM Last post by: Ryan |
|||
![]() |
16 | unitedcraig | 395 | 23rd April 2008 - 09:56 AM Last post by: unitedcraig |
|||
![]() |
18 | thewal | 340 | 28th March 2008 - 07:05 PM Last post by: Linda |
|||
![]() |
12 | Simon | 311 | 10th April 2008 - 04:09 AM Last post by: Emzi |
|||






Jun 19 2008, 04:47 AM







