Posts categorized: PHP
There are many ways to navigate a WordPress-powered site. There are archive links, category links, page links, internal post links, single post links, admin comment links, tag links, and many other types of navigational links. When it comes to navigating sequentially through your site’s chronological archive pages, category archives, and other types of archive pages, WordPress provides several useful template tags designed to dynamically link the pages together. Likewise, for single permalink post-views, WordPress provides a set of template tags that connects the pages together in chronologically sequential fashion.
Recently, I found myself on the front lines of WordPress’ somewhat complicated Media-Library system. The site that I was developing required a rather elaborate system of retrieving and displaying image attachments. So, using the latest version of WordPress (2.8.3 at the time), I found myself experimenting with as many template tags and custom functions as I could find. After much experimentation, I discovered the perfect solution, and along the way I collected a healthy collection of recipes for displaying image attachments and their various types of associated information.
Hello WordPress peeps! Did you know that WordPress makes it super-easy to display some basic statistics about your database performance? The information may be displayed publicly on your web page, slightly hidden in your source code, or entirely private so only you can see it. There are two basic statistics that are drop-dead easy to include on your pages:
I was recently putting together a site where I found it very useful to have a number of small areas of the site as separate chunks of code I could include in templates at will. The site wasn't unusual at all, it just never occurred to me to get this fine-grained with includes before, but I'm starting to do it now and I like it.
Close monitoring of your site’s PHP errors is crucial to operating a healthy, secure, and well-performing website. When left undetected, PHP errors can reduce performance, waste bandwidth, and leave your site vulnerable to malicious attack. PHP errors usually occur unpredictably and spontaneously, and may be triggered by even the slightest changes to your server configuration, database setup, or WordPress files. Even if your site appears to working properly on the surface, it may in fact be suffering from undetected PHP errors that should be fixed as soon as possible.
I usually recommend that people install WordPress at the root directory of their sites. Even if you intend to mostly use WordPress for a blog, and run it at
/blog/, you can still do that when WordPress is installed in the root directory. It's just a matter of changing some simple settings. But just because WordPress is installed and controlling your site from the root directory, that doesn't mean that the WordPress core files need to be located in that same location.
As you may recall, there are a ton of configuration tricks available for the WordPress
wp-config.php file. So many in fact, that I think many people may have missed some of the choice definitions aimed at optimizing WordPress performance. In this post, we’ll explore the best ways to improve your site’s performance with WordPress’
There are probably a couple ways to do this, but here is a really easy one:
ob_start(); the_content(); $content = ob_get_clean();
Many WordPress users know the
wp-config.php file as the key to the WordPress database. It is where you set the database name, username, password, and location (among other things like security keys, database prefix, and localized language).
Here's a screenshot of
wp-config.php (aka the WordPress configuration file) for those who may not yet be familiar:
By default, WordPress provides a decent way of including
<title></title> information for your posts, pages, and various archive views. This is important for usability and for better SEO. Most themes ship with some sort of title functionality baked right in, but for those that don't, you can add titles easily using WordPress’ wp_title tag. Using
wp_title(), we can specify several useful parameters, including:
There are many reasons you might want to get a unique ID for your
<body></body> tag. Let's say you want your header elements to be a different color on your About page, you could apply a bit of CSS via your theme's stylesheet (i.e.,
style.css). For example, you could target the About page with some styles something like this:
Many footers on websites contain text like "© 2009 Your Website". A good measure, surely. We can use some classic PHP and a built-in WordPress function to make this bit of text dynamic so that it will never need to be tampered with manually again. Here is the code to add to your theme template file (most likely