Tag Archive


2.7 8.10 9.04 9.10 100th acquisition advertising amd aol apache apple assp ati beta black hole blog browser bug building business caching callback CAN-SPAM can spam act centos chrome clamwin code collider comments compression computer css datacenter delayed development digg documentation earth Edward W. Felten email encryption encyclopedia of life enery eu exploit family fatherhood fedora firefox first plugin folding@home free freeware game Gaming gaming_rig gimp google guides hardware header history home house HPN-SSH icann IE image improvement Infoworld intel Internet ipv6 IT jail kubuntu ldap Leap Day lhc Linux locked files mac mail_server malware me memory microsoft misc money mouse moved Mozilla msdn mysql network solutions nvidia oem open-source os paint_shop_pro patch pc pentium phising php plugin post post-revision protocol ram RC record release review rollover safari samba scammers science SCP screenshots script script kiddies security SEO Series server service pack society software son Sony SP3 spam species squirellmail SSH storage stupidity styling sun tape tech Techozoic theme threaded tip tips ubuntu Unix update utility video card virtualization vista vlite vmware vsphere web weird WHS windows windows 7 wordpress work worm wsus XP xray

WordPress Theme Developers Tip – Call Dynamic CSS the Right Way

While developing my Techozoic theme, I’ve progressed from adding custom CSS into the head section, to having an external file and using $_GET variables to pull options from the database, to now I believe is the right way to do it, using add_filter and a custom query in WordPress. By using this new method I’ve done away with unsafe $_GET variables and can now use any builtin WP functions in the external file.
First you’ll need to edit your functions.php file and add this block of code.

	add_filter('query_vars', 'add_new_var_to_wp');
	function add_new_var_to_wp($public_query_vars) {
		$public_query_vars[] = 'my_theme_custom_var';
		//my_theme_custom_var is the name of the custom query variable that is created and how you reference it in the call to the file
		return $public_query_vars;
	}

This sets up WP to now accept a new variable in a query called my_theme_custom_var the format of the query would be http://www.yourblog.com/index.php?my_theme_custom_var=css . The ? mark tells WP that this is a query and the = sign tells what the query variable should be set to.
Now to actually setup the function that will call the external file. I found this gem when looking at how popular WP theme called Atahualpa handled it’s external CSS.

	add_action('template_redirect', 'my_theme_css_display');
	function my_theme_css_display(){
		$css = get_query_var('my_theme_custom_var');
		if ($css == 'css'){
			include_once (TEMPLATEPATH . '/style.php');
			exit;  //This stops WP from loading any further
		}
	}

This code now will check if a query is passed to WP with the value my_theme_custom_var and if it is and has the value of css then it includes the style.php file which is our dynamic CSS file. Then the code exits which stops any other functions from happening other wise the whole home page is outputted along with the style.php file, which isn’t what is needed only the file.
Now you can use any WP functions on the style.php file as it is included from the functions.php file which is a standard WP file.
Source : Will Norris

Wordpress Theme Options Framework Ver 2

As I’ve worked more on my theme and increased my coding skills I’ve added to my original theme option framework. I’ve become more aware of best practices of coding and WordPress, a big issue with the original framework was the way options were added to the wp_options database table. Each theme option got it’s own entry in the table, this might be okay for small theme, but I’ve grown to over 40 different options in my Techozoic theme. It was time to optimize, with the new framework the entries added to the wp_options table went from 40 to 2. I’ll continue below with code examples and explanations. As an added bonus I’ve included an example of how to pull your theme options into a external stylesheet, based off of this concept.

Read the rest of this entry »

WordPress Theme Dev Tip – Dynamic Stylesheets

WordPressA dynamic stylesheet using php is a powerful thing, when accompanied by a user options page it can really make a theme. I’ve recently done this to my Techozoic theme, and I’m going to share how this works and some time saving tips.

First you’ll want some way of letting the theme user choose what will change in the stylesheet, I explain how to do this with a theme options framework here. After you’ve got all the options set the way you want you need some way of getting those into your theme. At first I was just using <style></style> tags in the header of the theme, while this works it just isn’t an efficient way of writing a theme. What I wanted to do was have an external file that changed with the options but that could also be cached by the web browser, to improve performance, save bandwidth and overall have a better written theme.

Now if your using a framework similar to mine or your using mine then you know you have to pull some info from the WordPress database to fill in your variables from your option page. This posed the biggest problem because since this was an external page none of the WordPress functions would work. To get around this in the first version I just loaded the wp-config.php and wp-load.php files in the top of the file. This is bad practice because WordPress site owners can move these files around now and there is now way to know where to load these from. So I spotted the solution from another theme developer. Making an array of all the option values then using php GET variable on the external stylesheet. Now onto the actual code.

Read the rest of this entry »

Optimize your WordPress theme for Search Engines – Part 3

WordPressThis is the 3rd and final post about SEO for your WordPress theme. Meta keywords used to be what all search results where based on but over time webmaster began abusing this to gain rank, today some say that they are ignored all together when calculating search results but if they’re not then having your posts tags and categories added couldn’t hurt. This is the code goes between the <head> </head> tags. This also includes the meta description code from yesterday’s post.

<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php $excerpt = strip_tags(get_the_excerpt());
        echo $excerpt; if ( $cpage < 1 ) {}
else { echo (' - comment page '); echo ($cpage);} ?>" />
<meta name="keywords" content="
<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ','; }
$posttags = get_the_tags();if ($posttags) {foreach($posttags as $tag) {echo $tag->name . ','; } } ?>" />
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>

Line 5 thru 7 are the ones that deal with the keywords.

<meta name="keywords" content="
<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ','; }
$posttags = get_the_tags();if ($posttags) {foreach($posttags as $tag) {echo $tag->name . ','; } } ?>" />

This code depends on the loop code on line 1 to be able to pull the posts category and tags. This code basically pulls each category out and prints it out follow by a comma and then does the same with the tags. The comma is important because that is what separates the keywords. Even if this has marginal benefit it’s not that hard to implement and the cost as far as page load time should be minimal.
You see the whole series here. Be sure and rate each post, thanks.

Optimize your WordPress theme for Search Engines – Part 2

WordPress

Today I’m showing how to add your meta descripition to your blog. Google will use this as the description that shows up in it’s search results which can help with click through if you write good excerpts about your posts. If you don’t have a specific excerpt written then wordpress automatically grabs the first 55 words which may or may not be very descriptive of your post. It’s always a good practice to manually write your excerpt to give a summary of a post.

First I’ll post the code that needs to go into your header.php file between the <head> </head> then I’ll explain the pieces and what the do

<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php $excerpt = strip_tags(get_the_excerpt());
        echo $excerpt; if ( $cpage < 1 ) {}
else { echo (' - comment page '); echo ($cpage);} ?>" />
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>

The if (is_single() || is_page() ) determines if the current page is a single post or a single page. Next is this if ( have_posts() ) : while ( have_posts() ) : the_post(); this is mini loop to pull in the excerpt for the current post or page. Next this code pulls the excerpt and strips any html tags from it to display a clean excerpt $excerpt = strip_tags(get_the_excerpt()); echo $excerpt;. After that is the comment page code again to elimanate duplicate meta tags with google if ( $cpage < 1 ) {} else { echo (' - comment page '); echo ($cpage);}. The last bit of code is if it's just the home page then the tagline from the blog is displayed. That's it for section. Tomorrow I'll go over how to add your tags and categories to the meta keywords, some say search engines don't pay much attention to these but it doesn't hurt to have them. You can follow the whole series here. Be sure and rate each post, thanks.