Common Coding Mistakes in WordPress Plugins

While most people using WordPress are happy just to have an excelent blogging platform, there are some people we support who are seriously in to developing web based applications, and tweeking WordPress for the good and benefit of all.

While looking for the solution to a problem on a WordPress site we are setting up, we came accross this gem from Ozh Richard called Top 10 Most Common Coding Mistakes in WordPress Plugins. Actually, to give full credit, there are about eighteen common mistakes listed, and we have probably made (no surely we mean seen!) all of them at some time.

The top ten most frequent bad code bits are listed here for a quick reference, but for the detail and a good laugh, visit Top 10 Most Common Coding Mistakes in WordPress Plugins

  1. It’s not a plugin, it’s a mess
  2. Way too generic function names
  3. What? 87 new rows in the option table?
  4. You create new tables for what?
  5. No uninstall function
  6. Custom javascript or CSS added on each and every admin pages
  7. Plugin forms with no security, or nonces misunderstood
  8. Actions triggered from unchecked GET data
  9. Trust user input and pass it to SQL
  10. Localization done wrong

To read the full post, visit and enjoy Top 10 Most Common Coding Mistakes in WordPress Plugins.

While you are at it, check out the succinct The Definitive Guide To Using WordPress as a CMS on the same site

Getting Started With WordPress

Sometimes we get so used to using all the latest tools and tips that it is easy to forget that not everyone uses the Internet or a blogging tool like WordPress every day. Continuing our support series, we are publishing a few tips and tricks for getting started blogging with WordPress.

First of, in the Codex try

A question we often get asked is “What is the difference between a post and a page?”. There are a few key differences between a post and a page, which you should consider before setting out on your first site:
Pages are static entities that you create and edit, and then ere displayed using the Sidebar Widget. On the other hand posts are dynamic and listed in reverse chronological order on the blog home page. You can access posts by using Categories, Recent Posts or Archives and the RSS feed of the blog.

As a rule of thumb, use pages for content which you do not expect to change much, and posts for your daily news and fast changing information.

For example, if you are a startup business and sell a small number of products, you might have a page describing each product. However, to increase your coverage of keywords, you could produce a number of posts describing the products in different ways. Each of these landing posts should be optimized for a different keyword. As a result of doing this,

  • Your search traffic will increase because you’re targeting more keywords.
  • Your conversion rates will increase because your posts have relevant content related to the keywords.

Happy Blogging!

Improving Your Search Engine Results

Have you ever wondered how to get your business up to the top of Google or Yahoo! search results? Companies and individuals the world over have pondered this almost since Larry Page and Sergey Brin came up with the idea of PageRank (after Larry Page) and founded Google. Some specialist companies charge hundreds of pounds a month just to help you keep your business at the top of the Google results.

PageRank is a link analysis algorithm that assigns a numerical weighting to each element of a hyperlinked set of documents, such as the World Wide Web, with the purpose of measuring its relative importance within the set. The algorithm may be applied to any collection of entities with reciprocal quotations and references.

So how do you improve your position in the search results? Our advice is that if you want to reach the top of the Google search engine then you should build a Blog on your website, and start Blogging.

How do Blogs increase your placement in the Google search engine results? First, Blogs increase the amount of content on your website. Google spiders love to see content, and the more content you have the better. If you have enough content on your site, then Google will deem you an authority site on the topic. If you provide a service rather just having a page full of advertisements, then you get a better page ranking.

If you accept that Blogs are the way to go, the next question would be what Blog program to use? The top Internet Marketers in the world recommend WordPress, which is available at wordpress.org. For some options on starting a Blog see our WordPress Tags

Another advantage of WordPress is that it is a top pick for many search engines. WordPress creates site maps and automatically pings the search engines each time you update your Blog. The best news is that WordPress is FREE.

By making Blogging part of your daily schedule you can increase content on your site and help to improve your page ranking in the search engines. If you can increase your placement simply by writing a Blog, then why haven’t you started Blogging yet? We will be running a regular series of articles on Blogging, WordPress and Search Engine Results on this site to help you get started on the Internet. Why not come back every day and check us out?

For resources to help you get started with your first Blog, see the following links:

TechCo Training Demo Sites

If you are attending one of our training events or seminars, and want to view the sites listed in the demonstration, than this is the place to look.

Get a Free WordPress Blog at WordPress.com

If you want to check out WordPress for yourself, why not sign up for a free WordPress Blog at WordPress.com. There are some restrictions, but you can customise the theme and get blogging in minutes.

Just follow the simple steps below to set up your blog

  • Fill in the Username, Password, Email Address and agree to the fascinating terms of service
  • Fill in your domain name .wordpress.com/
  • Activate your blog by clicking on the link in the confirmation email

Check out the sample sites below

Some of the restriction of the free site are listed below

  • No Remote Publishing
  • No Post via e-mail
  • No Editing Update Services
  • Can not change the Permalink Settings
  • No Miscellaneous Settings

Business Card Web site
A business card Web site enables you to establish a Web presence for your company. It can contain basic information about your company, such as name, logo, a brief description, its location, contact information (e-mail, phone number, and fax, for example), and any other information about your business that you may want to add to the Web site.

You can either host your company Web site through your Internet service provider (ISP), through a hosting provider, or if you are running Microsoft® Windows® Small Business Server 2003, you could host the site on the Server. If you are planning to host the site yourself, you need to have registered an Internet domain name (for example, techcosupport.com) to access services on your server from the Internet.

KISS Demo
Click here for a sample site

Newest WordPress Plugins

Check out some of the latest WordPress plugins.

Bibs Random Content
Faster Image Insert

Please note that these have not all been tested and evaluated yet. We will evaluate them and comment in these pages. If you have any feedback on the Plugins please let the developers know directly via their own support mechanism.

We are curently testing the following

NextGEN Gallery Currently installed on Another World of Travel

Google XML Sitemaps Currently installed on a numbers of our WordPress sites.

Customising WordPress Using Templates

In order to customize a WordPress theme, you may need to decide which template file needs editing in order to provide a conditional display. Say you want to have a link to you favorite book retailers which only appears on your books page http://techcosupport.com/press/category/books/, then you may need to build a custom template for that page.

WordPress uses the Query String, the information contained within each link on your web site, to decide which template or set of templates will be used to display the page. If your visitor clicks on a link to a category page like http://techcosupport.com/press/category/books/, then WordPress looks for a template file that matches the category’s ID in the directory for the current theme. If it is missing, WordPress next looks for a generic category template file, category.php. Failing that archive.php and if that is missing the main theme template file, index.php.

In order to find out the category ID number go to Manage Categories and hover your mouse over your target category and the ID will show up in the link. Alternatively if you are editing a category, the ID will be displayed at the end of the url.

You then create your custom page with the name category-2.php in the case of http://techcosupport.com/press/category/books/. After that, when you display Books the custom page will display. Easy!

For more detail on the use of templates see Codex WordPress Template Hierarchy

Customising WordPress Using Page Templates

If you are considering customising WordPress, you may be interested to know that it can be configured to use custom Page Templates for different Pages. This means that several or all pages could have their own unique Page Templates and so appear completely different.

If you want to create a custom page template called MyTemplate, create a file called mytemplate.php. At the top of the file, put the following:
<?php
/*
Template Name: MyTemplate
*/
?>

Copy the content of another template (perhaps page.php or index.php) after the above five lines of code then you will only have to alter the HTML and PHP code, instead of creating it all from scratch. MyTemplate will now be available as a choice when you create or edit a new page. You can go ahead and customise this new template further without if affecting your default pages.

To select a template, there must be at least one custom Page Template available in the active theme. Once there is, toward the bottom of the Write Page administration panel (or on the sidebar, depending on which version of WordPress you are using) you will see there is a drop-down labeled Page Template. From there you can select which Template will be used when displaying this particular Page, and MyTemplate should now appear.

See Codex WordPress Creating your own Page Templates to find out how to create a custom Page Template.

WordPress Configuration Tips

When Setting up WordPress for the first time there are a few things you may need to do

Switch off WordPress comment
There is a simple way to shut down the comment system on a WordPress site. Turn off the comments on the Settings, Discussion page, Default article settings, which will disable comments on new posts. Then turn off the comments for all your existing posts.

Switch on Search Engine friendly URLs
The default WordPress uses web URLs which have question marks and lots of numbers in them. To improve this, click on Settings, Permalink Settings and change Custom Structure to read /%postname%/ and then Save Changes.

More Advanced Customisation

To exclude a cagegory or multiple categories from the front page
To block a category from the front page, in the sidebar find <?php wp_list_categories(); ?> and change it to <?php wp_list_categories('exclude=1'); ?> . Find which category number by looking at the category list. To block multiple categories use a comma seperated list like <?php wp_list_categories('exclude=1,4,5'); ?>

To sort categories alphabetically and include only the specified categories use <?php wp_list_categories('orderby=name&include=3,5,9,16'); ?>

For more category configuration possibilities see Codex WordPress Categories

To restrict pages to authenticated users
Check out WP-Sentry

A day in the life of a WordPress Blogger

Sometimes we work for customers who have high security environments, with restrictive settings that can cause problems for developers. An example recently occurred after a Microsoft security scare, and the security policy was tightened to exclude ActiveX controls and client side scripting. When I noticed the dreaded Information Bar drop down on IE7 helpfully warning me that my security settings do not allow websites to use ActiveX, I had that dread feeling you get when you realise you are not going to be able to do your planned jobs for today, without a lot of extra work.

Sure enough, all of our well crafted JavaScript based sites, clever dancing widgets and client side validation routines have ceased to work for my corporate customers. Even the years old multi-sites search on the TechCo Home Page has ceased to function. IE helpfully displays the search text in the URL querystring, but that is about it!

With a sinking heart I clicked on the log-in link of one of our WordPress blog sites, and attempted to log in. Well success, you can at least log in! Now for the acid test; can you post some information or edit a page? Sure enough, the wizzy icons above the edit window are no longer there. The Visual and HTML tabs do not allow you to flick between views because the other tab is not an active link. We are all Dooooomed!

But wait! The Save Draft facility on the right side appears to be a button. Click it and the reassuring message appears at the top of the screen that the Post has been saved. I can still work! How about the Publish Button? Yes, that works too! Praise be upon those wonderful developers at WordPress who had the foresight to consider the poor sap working a restricted environment with all the Ajax, ActiveX, and other JavaScript goodies turned off.

Think about that, you script kids who shout that a site without JavaScript and on hover events, is a legacy of the dark ages. Sometimes that old HTML Button has a place too!