martes, 15 de diciembre de 2009

put permanent metadata in your site

I am sure you have heard all about the importance of include keyword tags in your blog posts. It's a great way to get those search engines to bring more readers to your site.

When you create your blog in WordPress or Blogger, it creates metadata with your title and tag line. This is good, but put a lot of importance on that tagline. It throws out all those witty quips you wanted to use.

Now you can do both with a simple code embedded in your template. A little copy and paste will help you add common keywords that relate to you. Change the italicized and keep everything else.

<META NAME="description" CONTENT="slacker stay-at-home mom">
<META NAME="keywords" CONTENT="stay at home mom, special needs children">
<META NAME="Content-language" CONTENT="en">
<META NAME="author" CONTENT="mamikaze">
<META NAME="creation_date" CONTENT="November 19, 2006 21:09:01">
<META NAME="robots" CONTENT="all, index, follow">
<META name="copyright" content="&copy; 2006-2010 mamikaze">
Wordpress (self-hosted)
Go to Appearance > Editor > header.php > Insert the code before the tag

Go to Layout > edit html > insert the code before the tag

lunes, 14 de diciembre de 2009


You can use javascript to getElementByTag or getElementById, but what about class?

Like most plastic surgeons at this time of year, we are currently doing some development work on one of our client's back-ends! This involves some nipping and tucking of various code including the need to update the currency displayed in various fields should the end-user decide to change it.

If the currency was being displayed in just one field, we could apply an id and use the innerHTML property. However, in this case there are multiple fields that all display the currency.

As such, a span element was applied with the class "currency" and the following javascript function (based on this one) was used:

function currency_switch(currency){
var allHTMLTags=document.getElementsByTagName("span");
for (i=0; i if (allHTMLTags.className=='currency') {
allHTMLTags.innerHTML = currency;

martes, 1 de diciembre de 2009

Convert Text into PNG Image using PHP

We are currently working on a Wordpress MU theme that requires logos to be generated on the fly.

Fortunately the logos will just make use of a simple script font, but we still need some means of auto-generating them. We started with a great tutorial at Vision Master Designs and tweaked it slightly to fit in with Wordpress and the specification of the client.

Firstly, and fortunately, the name of each of the WPMU blogs would be the name required in the logo. This meant that we could pass "bloginfo('name')" in the text variable:

" />

Secondly, all the site names would be two words and these needed to be spread over two lines. This required a small addition to the code that simply replaces the whitespace between the two words with a PHP_EOL (end of line) call.

if (isset($_GET)):
$helloworld = $_GET;
$helloworld = str_replace(' ', PHP_EOL.' ', $helloworld);
else :
$helloworld = "Lifetime

With those two additions, we now have a theme that automatically generates logos on the fly. Perfect for a client who needs to be able to publish sites quickly and easily.

Exclude categories from Wordpress RSS

The Haycroft Media website uses a category for the flashy portfolio on the home page, which we want to hide from the Wordpress RSS feed

There are various options for doing this all detailed in a nice simple tutorial at We opted for option 2: Exclude categories in your template’s functions.php file, which simply involved the addition of a few lines of code to the functions.php file (just change the category id to that of the one you wish to omit):

function myFeedExcluder($query) {
if ($query is_feed) {
$query set('cat','-12');
return $query;

Strip wp_head in Wordpress

The wp_head() call in the header of most themes is an invitation for Wordpress to start inserting code into your nice tidy head.

However, we are of the opinon that if you don't need it, get rid of it. If you view the source of this site, you will see that we have removed the rsd link, the wml manifest link and the generator link. We're not using them, so we don't need them.

In addition, many Wordpress security blogs recommend removing the generator tag as it reveals the version of Wordpress you are using. So, say the good people at Wordpress discover a major security flaw in version 2.6 and you haven't upgraded to 2.7 yet, anyone with a knowledge of the flaw knows that your site is vulnerable.

So, how do we remove these pesky tags? Simply add the following to your themes functions.php file:

function striphead() {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
add_filter('the_generator', 'no_generator');
function no_generator() {
return '';
add_action('init', 'striphead');