A Quick WordPress Plugin: There Can Be Only One

It’s been over seven years since I last built or maintained a WordPress plugin, thanks in large part to the great community of WordPress plugin developers who share their hard work for the community as a whole. Yet, I finally ran into a situation that wasn’t handled by an available plugin. I patched this in my custom functions.php file with some help from code that I found here (thanks Craige!) and have cruised along for a good while, but I wanted to strengthen my solution while giving back to the WordPress community.

(TLDR – the WordPress community is awesome, and I published this plugin: There Can Be Only One)

My Goal

There should always be one (and only one!) sticky post visible at the top of my home page.

The Setup

I post many links and images on my site, which means the majority of my front page is made up of links elsewhere, and anything that I write is quickly lost in the stream. Sticky posts help to address this, allowing me to designate that a post should be shown at the top of my home page, regardless of whether it is the newest or not. Awesome!
[Read more…]

Web Performant WordPress »

Dave Rupert provides an excellent breakdown of how to speed up your WordPress-powered site. There's no excuse to not spend the time implementing these changes. Even if you're like me, and have already done a lot of the work, I'm willing to bet there's a step or two that will make your site even better. For me, it's the super-duper-easy cut-and-paste improvements to the htacess file to enable gzip and browser caching.

The Guardian Releases a Newsfeed Plugin

The Guardian just released a news feed plugin for WordPress as a part of its Open Platform initiative, making it easy for anyone to post Guardian stories to their WordPress-powered site in full, images and all. They’re working on other platforms as well.

Oh, and did I mention ads? Because they’re including ads and performance tracking in the stories too.

This is smart on so many levels – when so many other publishers are trying to lock everything down, the Guardian sees the future and is going to make money from it.

If you aren’t familiar with The Guardian’s efforts on the Web, you should be. They have an absolutely amazing team of developers building out their platform, which includes a content API, politics API and curated data sets.

As they put it “Our vision is to weave the Guardian into the fabric of the Internet, to become ‘of’ the web rather than ‘on’ the web.”

Change the Thesis Doctype and Add Meta Tags

I love using Thesis because it lets me focus on content, while providing all of the design and development hooks I need to tweak the theme as I see fit. I’ve dug in a good bit, and while I’m far from an expert, I’m confident that anything and everything I want to do is available to me.

One thing I discovered early is that the default doctype is XHTML Strict, which is great in many respects, but can add some complexity given enough design changes and external data sources.

In 1.6 I was able to add some custom code to change the doctype to XHTML Transitional, simplifying some issues I was having with IE 8. Those same reasons necessitated that I include a new meta tag as well. Thesis 1.7 changed the implementation methods, so I’m documenting the new, right way to modify the doctype and add items to the page head in the hope that others might find it useful.

Credit: I learned about of this from girlie, who was kind enough to point me in the right direction on the Thesis forums.

Modify the Thesis Doctype

Simply add this to custom_functions.php in your Thesis directory:

/* !Custom Doctype */
function custom_doctype() {
    return '< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';

Adding Meta Tags or Conditional Comments

This hadn’t occurred to me as I’m used to placing these directly in the code, but once girlie pointed me in the right direction I found it is a simpler solution.

  1. Go to the WordPress Dashboard
  2. Click Thesis in the sidebar – this should open the Site Options page. If it doesn’t, click the Site Options link
  3. Click the plus icon for the Additional Scripts box under Document Head
  4. Paste your tags, conditional comments and or anything else you’d like included in the <head>
  5. Click the save button and verify that it worked on your site

Thinking About Thesis?

How smart is your Theme?  How good is your support? Check out ThesisTheme for WordPress. If you’re thinking about purchasing Thesis, and I highly recommend you do, I’d appreciate it if you follow this link when you want to learn more or are ready to buy the theme.

Design, Feedback, WordPress and the Community

WordPress 2.4 Dashboard Snippet - Small Chris Messina has posted a great entry discussing the problems with open source design, with a focus on the new administrative interface for WordPress 2.4, which is generating a lot of discussion now that it is partially implemented in the nightly releases. As an avid user of WordPress and occasional plugin developer, I’ve been following the discussion from afar and fully agree with Chris that it is much too early for the design to be judged.

Hopefully Chris’ points about a lack of a visible design owner will be noted and acted upon. The project needs a strong, authoritative voice that can answer the design questions, lead the discussions and gather ramblings, compliments and complaints for future revisions. I fully believe the WordPress team has all of these issues covered, they just need to communicate it a bit more and demonstrate that they have it covered. We as a community also need to trust that they know what they’re doing – we are using their software after all, and judging by the amount of sites running WordPress, and the amount of people theming and building plugins for the platform, I’d say it has a loving community.

One of the first steps to resolve this issue is purely communication. I think it incumbent on the designer/dev team/Matt to release the final approved comps of the design, if for no other reason than it eliminates the uninformed complaints and can guide the conversation towards useful feedback. If people are going to take issue with the design – and people always take issue with design changes – they should at least see the plan in full, and there’s no reason to wait for final implementation for its debut. People love WordPress, and this is a major change; humans tend to dislike change when the object being modified is something with which they are comfortable. Doubly so when the changes are unknown.

Right now, all folks see is a Frankensteinian beast where once there was a well-known friend. Assuaging the fears is as easy as a quick post of a few screen shots, and a couple of words to describe the changes.

Fixing the WordPress Theme Reset Problem

As I posted in the WordPress forums I’ve run into an odd problem – WordPress occasionally resets my theme to the default version, which is annoying to say the least. After a lot of digging, I learned that the likely culprit is a bit of code in WP meant to protect the user from bad themes, but which has had the opposite effect for me and many other users. Luckily, others have already reported the bug and filed a patch, but the fix won’t be released until the next version of WordPress (2.4), which is slated for late January.

So, I decided to go out on a limb and make the change in my local version with the expectation that the file will be overwritten when I upgrade to the latest and greatest. So, I modified one line as indicated in Changeset 6325, commenting out line 269 of wp-settings.php, which contained validate_current_theme();.

I’m not positive that this will fix the issue, but all of the signs point in the right direction. As the fix is simple, and has been made to 2.4, I feel relatively confident that it is a safe move on my part. I’ll keep an eye on my site and post updates as needed.

Many thanks go out to the great folks constantly improving WordPress!

Update: Well, that theory didn’t last too long. When I hit the site this morning my theme had reset. Grrr.

WordPress Marketplace

Matt, the creator of WordPress, is laying the groundwork for a theme marketplace, the beginning of which he shares in his post Marketplace Idea. The idea is solid, and a step I’ve wanted to see for a while. I design and build my own themes, and will likely do so for a long time to come, but I have never built a theme to give away due to time constraints, so I’m not firmly in either target audience for the service. From this outside (though firmly in the ‘I love WordPress’ camp) vantage point I see some great benefits from this service:

  • The amount of people developing themes will increase, as professionals will be able to justify the time spent on theme creation. If billable hours are important to you, knowing that you are creating a product is worth spending some unpaid time up-front.
  • Following from the last point, the more professional developers and designers that are involved, the more high quality themes will be available.
  • Blog themes will gain in value. While I am a big fan of giving away work, having produced a couple of small plugins and scripts myself, it is important that we establish the fact that good work is worth paying for, and great work doubly so.
  • Good designs that are “retired” from a site could be put into circulation as a theme. I’ve had a couple of designs that I have replaced because I wanted something new on a site, not necessarily because the old design had any major flaws. Knowing that I could earn money, benefit others and/or gain recognition, I’d be more willing to spend some time making the small changes required to place it on the Marketplace. I’m not sure how this point relates to the requirement that the theme has not been published before.
  • This is a great promotion of open source code, without sacrificing the earnings that should come from hard work.

I’m really curious to see how the pricing will play out. Will the system set a price, or a set of prices, or will each theme producer set their own? Knowing only that a subset of users will have to pay to use your theme provides an interesting twist to setting your price and deciding on how much work to put into each theme.

I’m also excited to see how people make names for themselves, building reputations with the themes they produce. This could produce a neat cottage industry, or it could reduce the value of design and development in much the same manner as the “get a whole site for $500″ services that have existed for a while. The latter doesn’t worry me very much, as quality stands out, and I know quite a few top notch folks who make their living producing great work at fair prices far above the outsourced rates.

How to Include a Daily Digest of Ma.gnolia Links in Your Feeds

I’ve had a couple of folks ask me how I include a daily digest of all of my newly added Ma.gnolia links in my RSS feed, so I thought I would provide a very quick rundown.

FeedBurner Logo FeedBurner is the foundation of the functionality, as it makes it very easy to harness the wealth of feeds provided by Ma.gnolia. Once you’ve signed up for the free service and set up a site, click on the Optimize tab and then select LinkSplicer in the sidebar. At that point just follow the directions they provide you and select the “As a once-a-day summary only”. Once your site is using FeedBurner to serve your feeds, the Ma.gnolia links will show up automatically each night assuming you added at least one new link to your Ma.gnolia account.

Users of WordPress should check out the FeedBurner plugin by Steve Smith, which makes the transition to FeedBurner a smooth one.

Ma.gnolia Plugin 1.4 Released

Thanks to Rick and Emre for the excellent suggestions which prompted these improvements to the Ma.gnolia WordPress plugin:

  • Added the ability to pull bookmarks from group collections as well as those of individual people. Tags can be used with either, so you can pull bookmarks from the Web Design group that have been tagged with ‘css’.
  • Added ability to pull the Full feed from Ma.gnolia, which includes:
    • Thumbnails of each bookmark
    • The tags applied to each bookmark

    Please note, this is all or nothing, so you cannot just pull the image, or the image and description without the tags. Sorry, but that’s how it’s coming through and I spent too much time trying to find a way around it with a couple of different RSS parsers.

  • Changed the variable $username to $collection to fit the new model of pulling from groups or individuals. This shouldn’t impact your site as it is more of a clean-up task.
  • Added configuration option to enable/disable the link to view more Ma.gnolia bookmarks
  • Added the plugin to wp-plugins.net/ to ease updates for folks using Update Manager to track plugin updates (like me).

Please check out the official page to download the latest version and the new examples page to learn more about the plugin.

Note: for Users of 1.3: You should be able to drop this upgrade in place without changing any of your code. Please let me know if you notice any issues with your existing setup.

WordPress Database Error

I’ve been running into problems ever since I upgraded WordPress to 2.x (not sure if it was 2.0 or 2.1) with new posts. The first time a new post was was loaded into the browser, the server kicked out this error:

PHP Warning: mysql_affected_rows() [<a href='function.mysql-affected-rows'>function.mysql-affected-rows</a>]: A link to the server could not be established in /Users/alex/Dev/SilverSpider/site/wp-includes/wp-db.php on line 183

I searched to find an answer when I first ran into the problem, but never found a solution. Then, while I was working on the Ma.gnolia plugin, it cropped up again, so I began comparing my install to the stock set up and and found that my old wp-config.php contained some lines that are not included in the 2.x wp-config-sample.php:

$server = DB_HOST;
$loginsql = DB_USER;
$passsql = DB_PASSWORD;
$base = DB_NAME;

As I upgraded from 1.x, and the instructions say not to mess with the config file, I hadn’t looked into it as a possible source of the problem, but by removing this block of code, all appears to be running properly, at least in my local development environment. This post will either reinforce my theory or blow it to bits…

Show time!

It works!

Well, this post worked perfectly and did not generate an error. If you upgraded from 1.x to 2.x and are running into this problem, backup your wp-config.php and then remove that block of code and try it for yourself. Please let me know if that doesn’t work for you. I’ve filed a ticket so this will be resolved all official-like (3992).

Perhaps Not…

Damn it! The error just re-appeared after I edited this post. Grrr.

The New Ma.gnolia WordPress Plugin

Barry Price, the creator of the Ma.gnolia plugin for WordPress has set its development aside and has encouraged me to adopt the project. As I use the plugin heavily on this site, and I enjoy development, I decided to take him up on it.

This plugin makes it easy to output a list of your Ma.gnolia bookmarks anywhere on your site. You can set it to only pull bookmarks with a specific tag, which is great for listing sites related to a specific category or post.

Please download the plugin and provide me your feedback in the comments of this page. I’ll do my damnedest to fix any bugs you report and look forward to expanding it to be even more useful!


I’ve updated the plugin. Please go to the official page for the latest version: Ma.gnolia Plugin.
Magnolia WordPress Plugin

Make sure to join the Plugin group on Ma.gnolia to add your site to the list if you are using this plugin!


  • Drop the entire plugin folder into wp-content/plugins/ – the final paths will be:
    • wp-content/plugins/magnolia/last_rss.php
    • wp-content/plugins/magnolia/magnolia.php
  • Activate the plugin in the admin area of your wordpress install

To Use

This plugin is very basic at the moment, so all it takes once you’ve installed the plugin is a single line of PHP, inserted wherever you want the list of links to appear. You can pass the following variables to the plugin:

  • $username is the Ma.gnolia account to use, this is typically your account.
  • $numLinks sets the amount of links you want the tag to output, this defaults to 10.
  • $showDescriptions tells the tag whether or not it should include descriptions in the output. This defaults to “Do Not Show”.
  • $showPubDates tells the tag whether or not it should output the date the URL was bookmarked in Ma.gnolia. This defaults to “Do Not Show”.
  • $useMagnoliaLinks determines whether the links should point directly to the bookmarked URL, or the bookmark’s page on Ma.gnolia. This defaults to the Bookmark’s actual URL.
  • $tag allows you to pass in a tag to narrow down the list of results. Only bookmarks matching that tag will be output. This is empty by default, so it pulls all bookmarks regardless of their tags. Use a plus sign (+) to separate multi-word tags. For example “web+design”.

The output consists of an unordered list, each link contained in a separate list item tag.

Example of Usage

Here’s a snippet to output three bookmarks, with their associated descriptions from my bookmark list, regardless of the tag.

<?php magnolia('BaldTechnologist',3,1,0); ?>

Example Output

<li><a href="http://www.flickr.com/photos/17328648@N00/sets/1737284/" title="Cool &amp; Wacky Records - a photoset on Flickr:: No Description" class="ToolTip">Cool &amp; Wacky Records - a photoset on Flickr</a></li>
<li><a href="http://www.fortymedia.com/blog/post/59" title="Attention Mapping: The 10-Point Exercise:: Attention is the most fundamental unit of design. Once you get past the color schemes, typography, layouts, graphical treatments, etc., it all comes down to guiding and shaping the viewer’s attention." class="ToolTip">Attention Mapping: The 10-Point Exercise</a></li>
<li><a href="http://haha.nu/misc/html-tags-illustrated/" title="HTML Tags illustrated:: A collection of photos that demonstrate HTML tags." class="ToolTip">HTML Tags illustrated</a></li>
<li class="MagnoliaLink"><a href="http://ma.gnolia.com/people/BaldTechnologist/bookmarks" title="Alex Jones on Ma.gnolia::Browse through the sites and pages that I have added to my bookmark list on Ma.gnolia. If you're a member, add me as a contact!" class="ToolTip">View my bookmarks on Ma.gnolia</a></li>

Other Examples

Five Bookmarks Tagged with “Design”, No Descriptions, Pointing to the Original URL

<?php magnolia('BaldTechnologist',5,0,0,0,'design'); ?>

Ten Most Recent Bookmarks with their Descriptions and the Time they Were Saved to Ma.gnolia, Pointing to the Link’s Ma.gnolia URL

<?php magnolia('BaldTechnologist',10,1,0,0,'History'); ?>

Behind the Scenes

Barry Price built the first version of this plugin, and what you see here is a a modified version of his work the Last RSS Parser, which does much of the heavy lifting. At this point, Alex (BaldTechnologist on Ma.gnolia) has picked up the project and will be adding features as suggestions come in and time allows. If you have an idea, please contact me and I’ll see what I can do!

Contribute, for Free!

It’s easy to support this free plugin, and it won’t cost you a thing! Here are a few simple ways:

  • When you plan to buy something from Amazon, follow this link (Amazon.com). It won’t cost you anything, but it will add a small amount of your purchase to my account.
  • Write about the Ma.gnolia for WordPress plugin on your site
  • Add a link back to my site (www.silverspider.com) from yours
  • Drop me a line to say hi and let me know where you are running the plugin.

Changes Made

I’ve made some changes, both major and minor to the plugin, including:

  • Changed quote usage from single quotes to double quotes to improve parsing efficiency.
  • Improved comments within the script
  • Moved the feed parser class (Last RSS) to a separate file for ease of maintenance.
  • Various code, formatting and commenting changes

Upcoming Changes

These are not currently prioritized, but I want to add these features/implement these revisions:

  • Add CRON abilities to pre-cache feeds instead of waiting for a request
  • Add ability to search multiple tags (AND & OR)
  • Add the ability to pull from groups in addition to by tags
  • Documentation with some examples
  • Improve configuration options
  • …(this is where your suggestions come in)

Ma.gnolia & Me

Rick, a great Web Developer with whom I’ve worked in the past, and now count as a friend was kind enough to write about me being a featured linker on Ma.gnolia on his blog, Walking Around. In addittion to the pleasant surprise of seeing my name show up in the feed for his site, it was great to see that Rick has rediscovered Ma.gnolia, as I think it is a rockin’ tool that I hope lives up to his needs.

Speaking of tools, Barry Price, the creator of the Ma.gnolia plugin for WordPress has set its development aside and has encouraged me to adopt the project. As I use the plugin heavily on this site, and I enjoy development, I decided to take him up on the offer and have begun tweaking the plugin, with a goal of releasing a new version (likely 1.3) in the next week. The changes will be minor, but there are some features that I look forward to including in the near future. If you have any requests, please drop me a line!


I’ve posted version 1.3 of the Ma.gnolia plugin.

Favatars, WordPress and Me

A while back, I posted about implementing Favatars on this site. While I ran into many small issues, I was relatively happy with the feature. Since my upgrade to WP 1.5, I have wanted to re-implement the functionality without hacking WordPress. Luckily, Joen, with the help of Jeff Minard took the work I did (which was based on the work of Paul James) and turned the idea into a plugin which is now running on this site. The plugin was extremely simple to install and implement within my templates and is a great example of the maturity of WordPress and it community of users and developers.

WordPress Gallery2

WordPress Gallery2 – Just a quick self-reminder that this exists – perhaps to be used on this site.

“WPG2 is a WordPress Plug-in that embeds Gallery2 within WordPress to share photos, videos and any other Gallery2 content seamlessly into the WordPress Sidebar and Blog entries.”


From the developers of WordPress comes bbPress, a new, light weight forum package that follows five key principles (as taken from their site):
> 1. Open Source, always and forever
> 2. Less (code) is more
> 3. Simplicity is a feature
> 4. Speed and security are the foundation of any good user experience
> 5. Put the user first
> Every line of code is written with these principles in mind..

bbPress can be seen in action in the WordPress Support area, so check that area out for a demonstration of what it can do. For those who have visited the WordPress Support area in the past, you will be pleased with the fact that the forums are much faster.