[HOWTO] WordPress Child Themes

Here is an easy was to keep your custom edits to the theme php files.

We need to create a child theme that uses the garland core files for the main theme functions as well as and custom code you add, then when you update the theme from within wordpress only the parent theme will get changed, your child theme will remain intact!

first off we create a new folder within the themes dir and give it a name, inside it we put a style.css file. Ive chosen garland-redux for this example as were protecting my garland theme from changes…we still need the original garland-revisited theme folder, so dont go deleting it!

so your directory path will look like this:

wp-content
|_themes
        |_garland-revisited
        |_garland-redux
                       |_style.css

The format for the style.css file is simple, it just tells the child theme where the parent is:

/*
Theme Name: Garland-redux
Theme URI: http://www.pross.org.uk
Description: Testing WordPress Child Themes
Author: Simon Prosser
Author URI:http://www.pross.org.uk
Template: garland-revisited
Version: 1.0
.
This work, like WordPress, is released under GNU General Public License, version 2 (GPL).
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
.
*/

@import url('../garland-revisited/style.css');
[HOWTO] WordPress Child Themes

[HOWTO] Display number of spams stopped since your blog started.

So i wanted to display total number of spam coments blocked by askismet. Checking the the plugins source i found this function which returns the number:
[php]get_option(‘akismet_spam_count’);[/php]
Getting the blogs first post date was the tricky bit and required a database query:
[php]$firstpost = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND ID >0 LIMIT 1");[/php]
The query checks the first post above zero as most people delete post #1.

So the complete code is:
[php]<?php echo get_option(‘akismet_spam_count’); ?> Spams caught since
< ?php
$firstpost = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND ID >0 LIMIT 1");
echo gmdate(‘M Y’,strtotime($firstpost));
?>[/php]
the result looks like this:
10253 Spams caught since Jun 2006

[HOWTO] Display number of spams stopped since your blog started.