It’s been a couple of days since I started the Digging Into WordPress notes and takeaways outline, but I’m back with the next three chapters today. While going through the book and picking out my highlighted sections and notes, I find myself skipping over pages and pages worth on information to get the points I put in these posts.
However, that doesn’t mean that the content in the book isn’t relevant or useful. On the contrary, there is so much code in the book for extending WordPress functionality that it is simply impossible to put it into an outline like this. Seriously, if anything in these posts catches your eye, you should just pick up the book, either a print copy or the digital edition. And if there’s anything related to any of the topics I point out, you can probably bet on there being some code related to it in the book.
The amount of useful code is one of the greatest achievements of the book. Personally, I’ve been able to eliminate at least 3-4 plugins per theme that I’ve worked on since reading Digging Into WordPress, using the code snippets to achieve the same functionality within the theme files themselves. This saves on scripting on pages, server requests, page load times, and keeping plugins updated. For the price of the book and the time taken to change the themes around, I’m already saving time every week that I used to keep plugins updated and compatible.
Chapter 4. Theme Design and Development
Three ways to customize the WordPress loop functionality: query_posts(), WP_Query(), and get_posts().
Use the query_posts() function to modify the type of posts that are returned within a single loop. Place it before the loop.
Use WP_Query() to customize multiple loops and customize the output of each one. You can create any number and kind of loops.
Use get_posts() to create additional loops anywhere in a theme.
You don’t need the $query_string variable when using the WP_Query() function.
WordPress 3.3 and above includes a new function, is_main_query(), by which you can modify the main WP_Query() object.
The get_posts() function requies using an array for parameters, but this is the easiest and safest way to create multiple loops.
Worried about multiple loops? Sound scary? Don’t worry: it’s normal to have multiple loops going on in the same theme.
WordPress includes an RSS parser, making it easy to grab content from other sites to display on your own.
Child Themes are useful and easy to create. Just create a new folder and place a single style.css file with some standard theme language, and refer to the parent theme. Then customize at will!
Using a reset style.css? Should you have a default reset file, or just include the resets in your main style.css file? Including it rather than listing it as a separate file cuts down on server requests.
Use a plugin like CSS Optimizer to reduce the file size of your style.css file. It won’t be readable to you in that state, but will make your pages load faster.
There aren’t many takeaways from this chapter because of the amount of useful code snippets included for doing everything from importing Twitter updates to listing popular posts to enqueing jQuery. This is another chapter that goes much deeper into the mechanics of WordPress than I can get into in a simple list of key takeaways.
Chapter 5. Extending the Functionality of WordPress
Wonder why you get Hello Dolly with every install of WordPress? It was the first plugin ever created for WordPress and will probably be included with it until the end of time.
In many cases, you don’t need a plugin. Instead, you can add some lines of code to your PHP files to increase the functionality of WordPress. But sometimes, a plugin is the easiest way to get it done.
Try to keep the number of plugins to a minimum, however, as it will eliminate extra script processing, improving the speed of your pages.
Before installing a plugin, search online for problems and issues with it. If it’s not well supported or doesn’t function as advertised, you’ll soon find angry hordes complaining about it online.
If you download a bunch of plugins at once, install and activate them sequentially to avoid problems with one or compatibility issues which may break your WordPress experience.
Many plugins will make changes to the tables in your WordPress database. Well-designed plugins will clean up those changes if you later decide to uninstall the plugin.
There are numerous ways to disable plugins.
The functions.php file allows extending WordPress on a theme-by-theme basis with custom functions and scripts. Theme-specific, custom, and smaller script functions should be placed here. Site-wide functions should be done via plugin.
You can put entire plugins into the functions.php file, but it is easiest to do with with plugins that consist of just one file.
Modifying the WordPress core files is definitely not a best practice. Only do it if you have no other options, and make sure you back everything up.
Custom fields are one of the most powerful ways to use WordPress as a Content Management System, including large ecommerce websites.
Since WordPress 2.3, custom taxonomies have been available through the Taxonomy API. The three default taxonomies are category, post_tag, and link_category.
Chapter 6. Working with RSS Feeds
Don’t use relative URLs in your posts, because they can break when included in your RSS field.
Post comments have their own RSS feeds, but many people would rather subscribe to comments via email rather than an RSS reader.
Which type of RSS you feature (RSS 2.0, Atom, and so on) is no longer as important as it used to be, as most readers can now read multiple types of feed.
You’ll have to decide whether to set up your feeds to include the full post or just partial posts. There are arguments on both sides, from the free flow of information and giving customers what they want in the way they want, to avoiding content scrapers and encouraging people to visit your site for the full article.
Consider using FeedBurner for feed deliver for the analytics provided, and the halfway decent support of the system by Google, which acquired FeedBurner in 2007.
As a positive for content-focused websites, Google makes it easy to integrate AdSense with your feeds if you use FeedBurner.
You can easily redirect your feeds to FeedBurner with some code in your htaccess file.
For RSS statistics, FeedBurner is finally get some competition from sites and plugins such as FeedBlitz, RapidFeeds, FeedStats, and Feed Statistics.
WordPress has the capability to create custom feeds that include some categories, exclude others, segment by author, or exclude posts containing certain search terms.
If you’re not using some of the feed formats WordPress supports, you can redirect them to the feed type that you prefer.
Use the Feedstyler plugin to add some basic inline CSS styling to the content your pushing out via feed.
There is some extremely useful code for giving yourself a buffer of 5, 10, or however many minutes you want between a post being published and when it’s sent out via the feed. This gives you time to fix any last-second mistakes you see after hitting the Publish button.
As a last step, validate your feeds. There are multiple online feed validation services where you can enter the URL of your feed.
Chapters 4-6 were another tour de force of WordPress functionality and taking nearly any theme and making it better. Chapter 4 had a ton more code snippets that you can drop directly into your WordPress files and, with a little customization, greatly extend what a default WordPress installation can do, all without the use of messy plugins or paying for web development.
It might be another few days before I get to the next chapters, as I have some SEO content in the pipeline. But check back for more key takeaways from Digging Into WordPress as soon as I get a chance to put them together. Or, you can always subscribe to our RSS feed or Follow Traffic Motion on Facebook.