WordPress Themes

Recently, I’ve created two genuine WordPress themes from a CSS design.

If I knew well the plug-ins system, themes were a discovery.

And, hey, the theme system is very great and flexible.

Look for example K2 on www.getk2.com and its AJAX capabilities.

I’m planning to create a K2 design and migrate my blog to WordPress. Oh, and I’m going to develop and release a plug-in to implement languages categories, so I can continue to blog in french (mainly personal entries) and english (mainly technical articles).

In the while, here some functions I’ve just coded 😉

Dereckson’s WordPress functions

Functions I’ve written for these themes.
  1. /* * * * * * * * * * * * * * *
  2. * Filter 9 Theme functions *
  3. * * * * * * * * * * * * * */
  4.  
  5. //Prints alternatively textpost1 and textpost2
  6. function get_textpost_class() {
  7.         static $n = 0;
  8.         return ($n++ % 2 == 0) ? "textpost1" : "textpost2";
  9. }
  10.  
  11. //Prints image
  12. function the_image () {
  13.         global $id;
  14.         echo get_post_meta($id, "image", "true");
  15. }
  16.  
  17. //Returns true if the post is an image post
  18. function is_imagepost() {
  19.         global $id;
  20.         return get_post_meta($id, "image", "true");
  21. }
  22.  
  23. //Prints archive title
  24. function get_archive_title () {
  25.     if (is_category()) {
  26.         echo ‘Archive for the ‘, single_cat_title(), ‘ category’;
  27.     } elseif (is_day()) {
  28.         echo ‘Archive for the ‘, the_time(‘F jS, Y’);
  29.     } elseif (is_month()) {
  30.         echo ‘Archive for the ‘, the_time(‘F, Y’);
  31.     } elseif (is_year()) {
  32.         echo ‘Archive ‘, the_time(‘Y’);
  33.     } elseif (is_search()) {
  34.         echo ‘Search results’;
  35.     } elseif (is_author()) {
  36.         echo ‘Author archive’;
  37.     } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) {
  38.         echo ‘Blog archives’;
  39.     } else {
  40.         echo ‘Archive 42’;
  41.     } 
  42. }
  43.  
  44. /* * * * * * * * * * * * *
  45. * Curat Theme functions *
  46. * * * * * * * * * * * * */
  47.  
  48. function wp_get_numeral_archives($args = ) {
  49.         //Prints archives by Numărul
  50.         //Developed for curat | murdar by Sébastien Santoro aka Dereckson, W3 LIFT
  51.    
  52.         global $wp_locale, $wpdb;
  53.  
  54.         if ( is_array($args) )
  55.                 $r = &$args;
  56.         else
  57.                 parse_str($args, $r);
  58.  
  59.         $defaults = array(‘limit’ => , ‘format’ => ‘html’, ‘before’ => , ‘after’ => , ‘show_post_count’ => false);
  60.         $r = array_merge($defaults, $r);
  61.         extract($r);
  62.  
  63.         if ( != $limit ) {
  64.                 $limit = (int) $limit;
  65.                 $limit = ‘ LIMIT ‘.$limit;
  66.         }
  67.  
  68.         $add_hours = intval(get_option(‘gmt_offset’));
  69.         $add_minutes = intval(60 * (get_option(‘gmt_offset’)$add_hours));
  70.  
  71.         //Weekly archives
  72.         $start_of_week = get_option(‘start_of_week’);
  73.         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS week, YEAR(post_date) AS yr, DATE_FORMAT(post_date, ‘%Y-%m-%d’) AS yyyymmdd, count(ID) as posts FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit);
  74.         $arc_w_last = ;
  75.         $afterafter = $after;
  76.         if ( $arcresults ) {
  77.                 foreach ( $arcresults as $arcresult ) {
  78.                         if ( $arcresult->week != $arc_w_last ) {
  79.                                 $arc_year = $arcresult->yr;
  80.                                 $arc_w_last = $arcresult->week;
  81.                                 $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option(‘start_of_week’));
  82.                                 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week[‘start’]);
  83.                                 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week[‘end’]);
  84.                                 $url  = sprintf(‘%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d’, get_option(‘home’), , ‘?’, ‘=’, $arc_year, ‘&’, ‘=’, $arcresult->week);
  85.                                 $numarul = ($arc_year2005) * 525 + $arc_w_last;
  86.                                 $text = "Numărul $numarul";
  87.                                 if ($show_post_count)
  88.                                         $after = ‘ (‘.$arcresult->posts.‘)’.$afterafter;
  89.                                 echo get_archives_link($url, $text, $format, $before, $after);
  90.                                
  91.                         }
  92.                 }
  93.         }
  94. }
Parsed in 0.413 seconds | © 2007, Sébastien Santoro aka Dereckson, some rights reserved.
Released under BSD License, help wp_get_numeral_archives released in GPL, as based on existing WordPress function.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.