Archive for the ‘Personal Blog’ category

Donation buttons and self promotion in your plugins and themes.. yes or no?

December 14th, 2011

As regular readers might have noticed, I am a (more than) full time WordPress plugin and theme developer. I have spent the last few years doing this and have an intimate knowledge of WordPress. Because of this, like so many others, I have a base stock of plugins I tend to use for my clients’ sites which I use for a number of reasons.

The list of reasons tends to include the obvious things like ‘are they any good or not’ and ‘are they free’ (always a winner that one). However, one of my other criteria is to do with the existence of the other plethora of rubbish that some developers seem to chuck into their plugins almost as a matter of course.

This post was to do with donation buttons but I suppose that we can extend it to the following:

Automatic backlinking

When I looked at my sites XML Sitemap the other day I noticed that there was a nice little comment in there attributing the work to the guy that wrote the plugin. I find this incredibly annoying as, if it were an option in the plugin, it would almost certainly be turned off.

Donate buttons

I appreciate that plugins take time to write but little cheeky buttons that suggest they want $5 for a coffee is a particular annoyance of mine. I have one donate button and it’s on my homepage sidebar. This means that anyone wishing to give a donation can do but I never expect anyone to. The important thing is that whenever I go to the settings page on a plugin it’s not sitting there in a little box begging for some cash or, more suggestive, suggesting I look at their Amazon wishlist.

Flashing/fixed admin banners

I find that within some plugins people have gone as far as to write a nag box to show within the admin screens to ask for money or to show me a ‘sponsored’ news feed. Often the developer has copied and pasted some code to add this and managed to add it to that all roles can see it, not just Administrators.

News feeds

This one doesn’t bother me as much but I do appreciate an ‘off’ button. On the WordPress dashboard there are boxes linking to WordPress RSS feeds for plugin news and updates. Some developers like to put their little boxes on there too. If I were to allow people onto the admin backend of a site the last thing I would want to show them would be several boxes picking up content from RSS feeds I have no control over.

Social media buttons

The curse of social media now means that every man and his dog wants a Facebook or Twitter button on their site. I actually found myself considering getting a Twitter account the other day but then slipped out of that coma and came back to my senses. My personal feelings on people wasting their life posting ‘status updates’ aside, seeing these boxes splattered all over the admin systems that I use is as much of an annoyance as anything else. Social media sites are great for companies wishing to promote themselves and for people ‘getting back in touch’ (as often is an excuse given by Facebook fans.. what ever happened to email. Given it’s a new technology I know) and not to mention SEO but do I need a dedicated sidebar on admin pages for some plugins telling me what the developer ate from breakfast and is currently doing on the toilet.

HTML comment backlinks

I notice these all the time.. in fact I was speaking to a good friend about them last night when I mentioned I had written a major app which is being used by a few big name companies and he said that I need my name in there somewhere. I suppose my point is that if I have been paid to write something for someone then it’s their name that goes on it, not mine. It’s a little bit different with ‘free’ WordPress plugins where the author needs their credit but then again that’s that the Author Name and Author URI comment fields are for within each plugin and theme.. to attribute credit in a clear, consistent and unbiased/customer facing manner.

Forced suggested donations

I came across this idea when using a plugin this morning. I am working on a client site and wanted to remove a little blue box which keeps popping up suggesting I buy him a coffee or pay his mortgage or something. There was a convenient little button to dismiss the box which I clicked (who wouldn’t!) and it took me to his site which was splattered with both advertising, follow buttons and an explanation saying that if I were to pay him some money they he would ‘arrange for those boxes to flutter away’.

Security concerns

I have some concerns here.. in effect the developer has written a back door into the site (and he’s not the only one.. lots of plugins do it). He can easily log my site address or any other information sent with the request and note how often it’s being used. It’s stats heaven for the developer but rather concerning for anyone else. In effect in order for advertising to ‘flutter away’ he needs to add my site address to a list he has somewhere which will cause the advertising not to show. Feels a bit wrong to me.. thoughts anyone?

Conclusion

I tried to be impartial in this posting and intended to weigh up the pros and cons of this shameless self promotion (whoops) but clearly failed. It’s a shame that I really have to stop using, or just edit the code inside, some plugins because the person who wrote it feels that, for offering an open source plugin, they get carte blanche to advertise/nag/demand money from you until you jump through a hoop or two.

Plugins written for free should really be rated highly on the WordPress plugin directory. They should be talked about, celebrated and, as such, the developer will see both an improved site ranking/self popularity and most likely end up with more work because of it.

I have several plugins in the plugin repository myself and have offered tens of plugins on this site for free. In each one the only link to me or my name is the plugin author and site. The rest is on this site (sans social media and advertising and only the one small donate button if people really feel the need). I would love for a few more developers to take this approach as there are some really good plugins out there which I simply can not use out of the box because of one (or frequently more) of the afore mentioned reasons.

To see a list of the things I offer on this site then take a look at my downloads page

Ho ho ho and happy holidays everyone. I shall be working up until Christmas Eve undoubtedly but I hope to have written a new theme for this site by the n new year. Let’s see if it happens!

Simple custom post type features for WordPress

July 15th, 2011

I have been using custom post types in WordPress for a long time now…. In fact each new theme or plugin I write I tend to integrate a custom post type and some supplementary meta boxes here and there. If you have no idea what i’m talking about then this article probably isn’t for you… however read on and I shall explain briefly.

Custom post types are wonderful for parts of sites that don’t generally fit into the standard Post or Page model. For instance WP Ecommerce (the most popular WP shopping cart) has just started using custom post types for storing their products… you will get the idea, products being a custom post type. If I say that they are a way of storing things in WordPress that can, if needed, provide a way of administering these objects as if they were a page like any other.

Adding them yourself requires some code and adding the fields that will appear on the page will require some more. This isn’t what I want to go over right now as there is an easier way. To get an idea of what I mean, see the following screenshots…

Note the bottom three, they are custom post types

This admin interface is generated for you with 0 effort.

“Products” is generated by WP Ecommerce and my theme added “FAQs” and “Photography”. The second screenshot shows the admin interface, similar to the post/page editor, which is generated and the meta boxes which can be added very easily indeed to make it appear that way. The way that these can be added without writing any code would be to use one of the ‘More’ plugins…. These are More Fields, More Types and More Taxonomies… all freely available WordPress plugins although I tend not to use them these days (I write them into my themes instead). Take a look though.

This article was really to outline what you do with the data within these types in the real world. Of course storing the data is easy, using it requires some imagination really. The post type items are stored in the wp_posts table and the fields you add as meta data are stored in wp_usermeta. You can easily retrieve the information using standard WordPress functions.

The following function can be used to get all of the photography items and store them in an Array of Objects for looping and output any way you see fit…

function get_custom_post_type_items($custom_post_type) {
	$args = array(
	'post_type' => $custom_post_type,
	'post_status' => 'publish',
	'posts_per_page' =>-1,
	'orderby' => 'post_date',
	'order' => 'DESC'
	);

	$posts = new WP_Query($args);
	$return = array();

	if ($posts->have_posts()) {
		while ($posts->have_posts()) {
			$posts->the_post();

			$post_id = get_the_ID();

			$sub_post = new stdClass();
			$sub_post->post_id = $post_id;
			$sub_post->title = get_the_title();
			$sub_post->permalink = get_permalink($post_id);
			$sub_post->content = wpautop(get_the_content());
			$sub_post->meta_data = get_post_meta($post_id, 'meta_data_name, true);

			$return[] = $sub_post;
		}
	}

	wp_reset_query();

	return $return;
}

You can use this function in your functions.php file in your theme to be called by a page template or a shortcode if you add one to return the items you have added as custom post types. I have added a single meta data item called meta_data in each row which gets a custom field from the custom post type item called meta_data_name. In my Photography example I would just have more lines like this to get the various items from my custom meta box

$sub_post->png_image = get_post_meta($post_id, 'png_image_url, true);

Another good example use of this function would be for a featured items slider that you often see at the top of websites. One or more pages might have a portfolio item slider or a rotating banner or something. In that case you would call my function from your header.php file then loop through it outputting the appropriate HTML per line before using something like a jQuery call to construct the slider.

When you understand the applications for custom post types you might be finding yourself using them in more and more creative ways. I wrote a custom meta box a while back to link custom post type items to each other across different types. This was to allow staff member types to be linked to team and office types and so on. Then using this association you can output something like a dynamic organisational chart using a shortcode or a custom page template without having to hard code a thing.

This is a thinker, I imagine, for some people. Get in touch with me if you want any help putting these custom post types in place and utilising them on your site.

Want a website? Basic details on cost and what you are likely to be asked for…

July 14th, 2011

A lot of my clients seem to think, at least initially, that having a website built is a case of asking someone like me to write one and then their involvement stops. That is not the case as you are about to find out. This isn’t a rant or attack on people who don’t know the specifics of the web but hopefully will serve as a guide to those people or give other people like me a checklist to refine and give their clients…

First things first… Costs.

It doesn’t cost the earth to have a website written. A normal company is likely to want a presence on the net and that’s it. No need for huge fancy sites to be optimised to within an inch of their life and no need to even have a graphic designer involved. Of course you can do, and generally end up with a better site but if you want to keep things simple then it’s not necessary.

There are only really two ongoing costs for a website… domain name(s) and website hosting.

Domain Names

A domain name is very cheap indeed although costs do vary. In the past I have used a few registraars and people always have their favourites. I use Europe Registry for this site but have just registered www.letsboat.co.uk with 123-reg (aff link) for a grand total of £7 for two years.

Web Hosting

Many website developers such as myself will offer to host the site for you at £X per year. This is a good idea if you want a lot of support but ultimately it’s cheaper to do it yourself and pay a developer when (if) things go wrong. This site is hosted with imountain however I wouldn’t recommend them at all. It costs me $10 per month but I find it very slow here in the UK. I tend to recommend Hostgator (aff link) to my clients. All you need for your own website is their most basic package although I would recommend their Baby plan in case you want to host more than one site using the same account. you can pay monthly with most hosts although you only usually get the quoted prices if you pay for two or three years up front. Depending on your financial situation this might be worth doing. If you go to hostgator.com and use tortoise25 as the coupon code you will get 25% off the quoted price if it helps.

Website Development

No one, if they can help it, writes sites in pure code any more. They are a nightmare to maintain and generally not very good. Also, as the client, you end up paying for a developer to make the smallest change. This is where WordPress comes in. WordPress, a content management system (CMS), allows you and developers to write sites (like this one in fact) quite quickly and with a massive range of free themes and plugins to make sites do whatever you want them to. Galleries, shops, video players, etc… All doable without much more than a few simple steps.

Installing WordPress requires you to get a PHP enabled server, set up a MySQL database, FTP up the WordPress files found at WordPress.org, apply the theme, add some plugins and write the content in. Sounds like a lot but when you do it for a living it doesn’t take long to get something up there. However it’s kind of like car maintenance.. you think you can service it yourself and you know that, in principle, replacing a few engine consumables is an easy job and takes a mechanic only a couple of hours. Then you start the job and it takes two days and never does run right after that. See the parallel there? :)

That’s it…. you never have to pay for content updates and you can always contact me for advice/help. If you hadn’t noticed, I’m a bit of a WordPress enthusiast. But then why not when WordPress is used for a huge number of sites on the internet (50,000,000 I think was the last count I read).

What do you need to provide to a Website Developer?

Simple enough question to ask, hard question to answer really. Here is a very basic list…

  • Content
  • Look and feel
  • Gather resources to use

And then for any site with an ecommerce aspect:

  • Products
  • Payment processor (Paypal, Clickbank, Sagepay, etc…)
  • Gather resources for download or delivery

Let me expand on these…

Content is self explanatory. I recommend firstly thinking about how many pages you want on the site and then jotting down, in something like Word, the content for each page. Images to compliment text is always a nice addition but can be done later. Additionally with a domain and a site you might want to let people get in touch with you. Have a think about what phone numbers (if any) and email addresses you want public or if you just want a contact form.

Look and feel is something that will definitely need to be expanded on. If you have a look at a few themes around the internet. There are literally thousands of them out there, loads free and others premium. Either is ok and neither better than the other. WordPress has it’s own showcase of free themes (required to be free to be in the list!). Someone like myself will firstly ask if you want a graphic designer involved, at which stage this process will be escalated to another level of cost and complexity. However, if you want something basic then a free theme will do. There are a large number of ‘framework’ based themes for free out there which allow people to edit their theme without touching the code. They tend to be very basic but might be a good starter. Otherwise there are even more standard themes about which can be modified to suit if need be. I normally recommend that people give up to three themes from the directory they like and then a new theme can be made which incorporates the better features of each.

Gathering resources is really just a cursory note for you to gather any images or logos (your company logo for example) in digital form to be added to the site. They need to be as high a quality as you can find. Images like logos should really be in JPG, PNG or GIF format and be bigger than needed so they can be trimmed to fit for the site. You can make images smaller and retain quality but not make them bigger.

Ecommerce aspects really are similar… Products is just something, as before, for you to think about. The descriptions for the products, the pricing, images and ways of getting hold of them (postage, pdf, etc..)

Payment processor is what we call the way in which people are asked to pay for their items. Normally Paypal is the standard for small sites. People tend to have accounts via eBay these days anyway. Other types of processor are available but tend to incur monthly costs (£20/month I think for Sagepay). Paypal is the easiest if you want to keep ongoing costs down. The requirement to sell is that you have a premier or business account. To do it you just need to login and look at your account settings then jump the hoops to update your account. This simply involves linking a bank account to you Paypal account (takes a few days, best done in advance of being needed). Nothing official otherwise needed.

Gathering resources is, again, just putting together the images and the content for the products. There are several shopping carts for use for downloads and ecommerce within WordPress.

SEO

Perhaps the buzzword of the net these days. I’ve not yet met someone that hasn’t heard the acronym although often people don’t know what it means… only that they want it. Plugins exist for free for WordPress to allow you to add your site to Google and other search engines and to allow you to compliment your content with the right sort of data to get you noticed. There are quite a few guides on the internet to help you through this.

Summary

So what was the point of all that then? Well… hopefully now you shall know about the sorts of things you are likely to be asked for when wanting a website and will be prepared for your initial conversation with website developers if that’s the direction you want to go.

By all means get in touch with me to go over any project you have in mind or even just to get an idea of how much it would cost for me to do it all for you. Take a look at some of the sites I have done in the past on my Portfolio page or get in touch using either of my contact or get a quote forms.

PHP source code protection – the basics

April 2nd, 2011

If you have ever sold or considered selling your code/application you would most likely have thought, if only briefly, about stopping people from buying a copy of your code then passing it to their ten friends (disclaimer: not all people have ten friends! some have more (or less!)) for free.

‘Why not add a product key?’ you ask!

Well yes a product key would do the job and avert the efforts of a portion of these people but obviously when using an interpreted/scripted language such as PHP they will be able to open up your source code, remove any license checking code and then pass the ‘cracked’ version around as before. Generally it’s not hard to find this sort of code… simply look for any filenames which hint at ‘licensing’ or ‘auth’, open them up (usually very small files) and put a ‘return true;’ at the start of the key checking method.  As I said this method stops a large portion of people from passing it around so it’s still worth doing.

What about a ‘call home’ script?

Same story here I’m afraid but more convenient for the seller (and you can get some lovely stats on the people using your code). A Call Home script is simply a piece of code that runs on the client site (per page load? per admin page load? every day on a CRON job?) and in effect sends a request back to a central server run by the code seller (you?) to simply authenticate sites. If, for example, example.com buys a script from my_premiumscripts.com then installs it on their server… Every so often the example.com server will call the my_premiumscripts.com server and have the following conversation:

example.com (e): Dude?
my_premiumscripts.com (m): Dude?
e: So… I’m just checking in with you, everything ok?
m: Ah great stuff, yes I see you purchased a copy of my code. Feel free to carry on using it.
e: Brilliant!
m: Indeed. don’t forget to check in with me tomorrow though.
e: Ok bye!

Or they could say this:

example_dotcomsmate.com (e): Dude?
my_premiumscripts.com (m): Dude?
e: So… I’m just checking in with you, everything ok?
m: Who are you again?
e: I’m a new site you don’t know about. I got your script from a friend (torrent? friend? unauthorised reseller?)
m: Oh ok, that’s fine with me but you have to send me some money first before you can use the software.
e: What? Hey I just want to have a look at it for a few days (years)
m: Nope sorry, I am going to deactivate the software on your site now. Bye!
e: Oh ok, bye!

Ok I jazzed up the conversation a bit but you get the idea. Call home scripts work really well from a protection point of view but have one really major drawback… they require you, as the seller, to have a 100% uptime server and it requires either the client server or the clients users to each initiate a request to that server. This means that both your server is going to get a lot of, what can only be described as, logging traffic (useless to everyone really) and the clients (servers or client machines) are going to get a worse (slower) user experience because of it. That and if you ever decide to move server or domain for the script then there is a lot of admin to do.

Either way there is the potential for you lose out on potential lovely cash. What we need is to be able to use the product key method with a way of stopping people from getting at the source code. There are a few ways to do this, some more awkward than others (both for the purchaser and the developer). The two worth mentioning are:

Code Encryption

This is the daddy of code protection. If your code is protected by an encryption algorithm then people are unable to look at the source code no matter how resourceful. The real downside of this is that you have to force your users to install additional server software before your code will run on their server. No simple FTP it up and start using it type system; this method is likely to involve your server host and a support ticket or two. An example of this would be any system that uses Ioncube Loader which, I understand to be, the same sort of thing.

Code Obfuscation

This is the lighter and more manageable version of the above. Whenever you look at an obfuscated file it will appear jibberish to the reader. PHP can interpret it because it doesn’t care whether a variable or function/method has a name which is human readable or not. Obfuscation works by removing all whitespace, renaming functions and variables and swapping out ascii text for a different characterset/encoding which is not immediately obvious to a novice that it’s text. Often these scripts make use of nested loops, dummy methods and evaluated code (code as a string which has then had the eval() function passed over it. Base64 encoding is popular but very easy to spot and decode to it’s use is on the decline. No additional software is required to run obfuscated code, it’s just a pain when there is an error in the code and the developer, for example, is on holiday for the next month! The downside of this for the developer is that it can be decoded and reverted to something resembling it’s original form (minus original function and variable names) by simply working backwards. Well… it’s not simple at all but is doable! Many virus script writers use this method of hiding a scripts intention. I have had to decode a few myself and it’s not fun.

Recommendations

My only recommendation is going to be to use neither and just go with a simple product key. Yes you are going to get taken for a ride by some people who want to redistribute it amongst their friends but think about it… they can’t get any updates from you, no support and if their source of the code disappears then they might even come and buy from you in the first place.

The key is to constantly be working on your scripts/applications. Don’t settle on a single version for too long, encourage a good community around the work and most importantly don’t rip people off in the first place… if the price is reasonable then people will happily pay it. A cheaper price is also a nice reason to offer sightly less involved support. It’s also a possible avenue of further income, premium support etc..

The real issue with any form of code protection is that updates and critical fixes won’t work without the original developer putting a new package together and, often, the entire fileset being replaced. If something goes wrong and the developer is not available then the job can not be outsourced which causes more issues. This is why I would always recommend you stand behind a well written Terms and Conditions document which must be agreed before the software can be used. Generally a block in the code is a challenge to be overcome, a legal document that requires signing and makes you liable is not!

Thanks for reading!

nb: example.com, example_dotcomsmate.com and my_premiumscripts.com are fabricated and although they might exist have no relation to the content in this article.

Apple releases Beatles back catalog

November 16th, 2010

Apple, a few days ago, changed their homepage to say something big was coming to iTunes and it would be released today at 3pm GMT. I think that the world was then rubbing their hands together in sheer anticipation of what goodies could be announced and included. I went out with my Son for the day but made sure that I took my mobile with me to check the site at the right time (ish) in the day.

The time came and I expectantly checked the site only to be greeted with a picture of the Beatles in their younger years. Given the wait and the suspense I would have expected something just a little bit more interesting than the opportunity to spend more money on iTunes on something that most beatles fans will have on CD or other media already. Let’s hope the next time they announce something big coming that it’s a 2nd generation iPad or Apps for Apple TV… now those I would sit up all night constantly refreshing my browser to see!

Better luck next time Apple. Love the product and the marketing strategy but in this case what was offered wasn’t worth the wait.

What exactly do you get from good customer service?

November 8th, 2010

superseanIt’s been a while I know… moving house, holidays and loads of work have made it a little bit of a slow couple of months for inspiring things to say. Regardless, today’s topic is a simple question and in theory a number of possible answers..

What exactly do you get from good customer service?

I work for a number of friends and clients and find myself in the position where I am constantly dishing out advice whether helpful, requested or otherwise. I work on a forum (at Newmedias), I do a great deal of email support and I answer a lot of questions from clients and customers.

Of course working in IT means that everyone assumes you know everything about everything and call whenever they can’t get their email to work or computer to start (i’m a web developer!). So why oh why do we bother helping people out at all? Well.. there are a number of reasons that I came up with:

  • The money
  • The challenge
  • The self gratification
  • That thank you you get on helping another person out
  • The favour you are then owed (assuming the person you helped didn’t pay for the privilege)
  • The handouts (such as the comedy Photoshop job that someone did for me this evening (right top))
  • The money

A short list, I know, but feel free to post your own! I think that we all do it for a combination of those reasons as opposed to just one. Even if you are paid to help it’s still nice to help people out and go that extra mile. You wouldn’t, and don’t(!), expect to see it everywhere but as a person in need you are always very relieved to find that one helpful person who makes it all better for you. I am not saying that I am always that person but I must admit I do try (when it’s convenient for me to do so).

From a business perspective the customer service is incredibly important although I do wonder if some companies strategically position their helpful (and local??) staff where they are likely to need it. For example my ISP and phone are provided by a company that sounds a lot like Squawk Squawk and I have had nothing but problems with them for three years. You wonder why I am still with them… that’s easy.. they are cheap! However, being cheap does not exclude you from having to give a good service to your customers. My internet at my old house was intermittent at best and in my new house it seems to have stopped at 3mb (i’m paying for 20mb!). Now when I took out the contract (fixed term.. no escape!) I was assured that all would be fine… I got lots of glossy welcome literature (which went swiftly into the bin) and the service was running by the due date. Then it all went down hill… internet service was incredibly slow and flicked on and off seemingly randomly. On calling technical support I was asked to plug my computer into the router with a cable instead of wireless, I was asked to change micro filters and use a different phone socket. All completely pointless and fruitless but the support operatives would not take no for an answer. In the end I got a little bit grumpy with the person on the phone and asked to be transferred to second line support. On connection I was greeted by someone who I could understand and who noted a fault on the line and had it fixed within a few minutes.

The moral of the story was not to dig at Squawk Squawks appalling service (and believe me it has been dire!) but to point out that the useful staff are hidden behind a wall of incompetence whose sole use is to fend off the people who need to turn it off and on again. A good business practice? I don’t know but it seems effective for all except those with any computer knowledge who they manage to infuriate. Luckily, like good support staff, those are in short supply as well.

To conclude, what do you get for good customer service.. the answer if of course a comedy Photoshop drawing to put a smile on your face :)

NewMedias get’s it’s third musketeer!

May 21st, 2010

logoThose of you who know me from the NewMedias Your Members project will remember that for years it has been a two man band. Some were sceptical about the future of Your Members and whether it was just going to fizzle away like so many other WordPress plugins. I am pleased to now tell you that actually no, we aren’t going anywhere and in fact will be trying to get things moving again with help of the latest member of the team, Glenn Pegden. Glenn has a varied background, likes long walks on the beach and candle lit dinners. I understand he also knows a thing or two about sales and therefore he will be kicking myself and Tim Nash into shape to get the plugin(s) updated, pretty and unmissable!

Current plans include a whole new website just for the Your Members plugin to house things like… wait for it… documentation and a proper list of the things it can actually do! We have recently released YM version 1.6 which is the best version yet! We hope to get some feedback and tweets to the new YM Twitter account for things that you, the community, would like to see and then get the next version out to you sometime in the next couple of months.

Any questions about the plugin, the project or Glenns vital statistics then you can get in touch with us at newmedias.co.uk or use my site contact form and we shall get back to you.

How to convert your site to WordPress

March 16th, 2010

Wordpress LogoI recently had a conversation with someone who had decided to come to WordPress to take advantage of a plugin or two and wanted to know how to get an existing site into the correct theme structure as required. It took a lengthy email or two to explain but it struck me that lots of people must be asking the same questions over and over. So in this post i shall try to explain how to get a theme together, or rather where to start

So… first, a bit of logic

Logically speaking a standard layout web page can be split into four distinct areas as follows:

  • Header
  • Footer
  • Sidebar(s)
  • Content

And as such WordPress uses different theme files to render the appropriate sections. We need to split our HTML page into those different files. There are, however, lines of code that WordPress needs you to put into each of these files and so tbe best way todo this without missing anything is to recycle another theme. So… go to your WordPress install and visit /wp-content/themes/ and…

  1. Duplicate the directory called ‘default
  2. Open style.css in a text editor and edit the name of the theme and any other information you feel like
  3. Either remove or replace screenshot.jpg from the theme directory so it looks different in the theme menu

That’s it, you now have a skeleton to work from and it’s time to make it look like your site. Let’s assume you have a simple brochureware site and, therefore, don’t need any blog type pages. Largely these sites have a standard consistent layout on each page (often except the home page but that difference is for another tutorial) and WordPress uses this consistency to slot in the appropriate information for each page. We do this by…

  1. Choose a short yet typical page from your site and view the HTML source
  2. Open 4 separate text files from the new theme directory in your favourite text editor. They are: header.php, footer.php, sidebar.php and page.php
  3. From the HTML source take the top section of code (usually as far as the content and sidebar code inclusive of a menu assuming you are using a top horizontal bar navigation) and place it into header.php making sure to preserve the obvious dynamic sections of code (anything between <?php and ?> can be assumed to be dynamic)
  4. Do the same with the footer into footer.php (the section below the content and sidebar that often contains SEO links and copyright notices)
  5. The remaining block should contain the content and sidebar code… simply cut out the sidebar code into sidebar.php
  6. Finally split the content code into the bit before the text and the bit after the text (ie: layout code stripping out the text itself). Then paste these sections around the ‘while’ loop within page.php.
  7. (optional) copy your stylesheet into style.css making sure to preserve the comment at the top of the file as this is used by WordPress to define the theme and without which will not pick up any of the code.

Step 6 will likely be the most difficult to do as there are three or four important lines of PHP code in there. Firstly the line that reads <?php get_header(); ?> is the code that calls header.php. Likewise <?php get_footer(); ?> and <?php get_sidebar(); ?> call their appropriate namesakes. Make sure that they are in the correct logical positions for the page to render in the right order.

The Loop

The hardest section is what is called ‘the loop’ by WordPress bods. This is the section of code that shows the post(s) from the database relative to the page you are looking at. The Loop often falls into the following form:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 <div id="post-<?php the_ID(); ?>">
 <h2><?php the_title(); ?></h2>
 <div>
 <?php the_content('<p>Read the rest of this page &raquo;</p>'); ?>

 <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

 </div>
 </div>
 <?php endwhile; endif; ?>

You shouldn’t really need to change any of the code itself but you might need to edit the encapsulating HTML to make your styles fit in. For example if your page titles are not in H2 tags then you need to change it to suit etc etc…

Testing it!

This will always be a case of trial and error until you know what you are doing so don’t worry if it all goes pear shaped. That’s what the undo button is for!

To test that your theme is working properly then you need to visit your sites back end at /wp-admin and click the link on the left hand side called ‘appearance‘. The themes page will appear and to activate your theme you simply find it in the list and click ‘activate’. Then view the front end of the site and see what it looks like.

At this stage you might be confused because the home page looks different to the rest of the site. This is because, by default, WordPress uses the index.php file from your theme directory to generate the home page. To change this visit the settings -> reading page from the left menu and use the dropdown box to choose an appropriate page to be used for the home page.

What’s next?

Ok so your theme looks like it did before you spent hours making the them for the WordPress site… why on earth are we using WordPress at all you ask! Well if you were to create a new page for your old site then you would have to duplicate an HTML file, trawl through code (or look at Dreamweaver or another WYSIWYG) to find the sections to replace before uploading to your site and updating the links in the various menus as appropriate. With WordPress you just add a ‘page‘ using the nice admin system and it’s all done for you.

I always tell my clients to go and have a look at the WordPress plugins directory for ideas and things to ad to their site. A word of warning though, some plugins conflict with others and too many plugins might slow your site down considerably. Over time you will get used to a core few you know and trust.

Feel free to ask me any questions about WordPress, PHP or other and hopefully I will be able to help you decide what’s the best direction for your site to take. Expect a lecture about how good WordPress is though!