Tag Archives: bloginfo()

10+ WordPress Functions Every Developer Should Know About

add_action($tag, $function_to_add, $priority, $accepted_args)
do_action($tag, $arg)

add_action() attaches a function to a specific action, which is then triggered by a do_action() call somewhere during execution. This can be used to execute a group of functions using the $priority parameter to determine order (optional), and arguments can be passed through the $accepted_args parameter. Below are a few examples of how this is used in the WordPress platform:

WordPress Logo

  • do_action(‘deleted_post’)
    This is executed after a post or page is deleted, and post or page ID is passed as a parameter.  This allows you add custom functionality whenever a post is deleted.  For example, lets say you want to be notified every time a post is deleted.  You can create a function to send the e-mail, and execute add_action(‘deleted_post’, ‘notify_when_deleted’, 10, $email). After that, when do_action(‘deleted_post’) is called, the notify_when_deleted() function will be called.
  • do_action(‘wp_head’)
    The wp_head action is traditionally called within a theme’s header.  If you wanted to create an SEO plugin, you could very easily add an action to wp_head to display meta tags. Continue reading 10+ WordPress Functions Every Developer Should Know About

Optimize your WordPress 2.8.4 installation

Large traffic spikes can put an enormous amount of strain on the typical web server, especially low-level hosting plans.  These often occur after appearing on the front page of a social media site (Digg).  While WordPress is well-equipped and can handle these requests, it was designed to be a quick easy install, and is not fully optimized out-of-the-box.  WordPress can be used for high traffic sites, but some features should be implemented to keep your web server running smoothly, and also as a precautionary measure for smaller sites.

Use WP Minify

WP Minify will consolidate and minify and compress JS and CSS files, reducing the number of HTTP requests and decreasing the overall size of the downloaded file.

Use WP Super Cache

WP Super Cache generates static HTML files based on your blog/site content and serves that instead of processing the PHP scripts each time someone visits the site.  This drastically speeds up most WordPress installations.

Remove unnecessary database queries

Themes are built so that they can be applied to mostly any WordPress installation, though chances are you will initially set the title and description and leave them the same.  A typical theme will contain the following lines of code within the header.php file:

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

The aforementioned bloginfo() functions can be replaced with static values, which will prevent the overhead from PHP and any additional database queries. For example, bloginfo(‘name’) could be replaced with My Blog Name. You’ll want to check the other theme files too.

Use Google FeedBurner

Using Google’s feed service will help reduce the load on your server.  It basically works like this:

  1. User visits your feed URL.
  2. User is redirected to the Google feed URL by the WordPress FeedBurner plugin.
  3. Content is served from their servers instead of yours.
  4. …also has the added bonus of including MANY other features, including e-mail subscriptions, formatting for every major RSS platform, pinging, etc.

Install and use Google Gears

WordPress comes with Google Gears support, an application that allows files to be stored locally. Google Gears is integrated with newer versions of Google Chrome, Mozilla Firefox, and Internet Explorer.  While this won’t speed up the front-end of the site, it will reduce the number of HTTP requests on the back-end, drastically speeding up the administration panels, and indirectly helping to reduce the overall load on the server.

Remember, WordPress uses their own software on wordpress.com to serve content to over 170,000 bloggers and many, many more visitors.  This is proof that WordPress works at the enterprise level, although they have very advanced servers and configurations in order to achieve this.  While the average person does not have a need for that sort of environment, some tweaking should still be done to keep server loads down, and keep our carbon footprint at a minimum.