Simple WordPress Twitter follower count snippet

Following on the idea from this post, sometimes a full blown Twitter plugin is too much. Luckily Twitter has a rich API that is ripe for the taking of information. The API console is of great use to find how to properly format the API requests. This code below will output the number of followers specified by the username passed to the function wrapped in a link to the page that allows the visitor to easily follow the user.
Continue reading

Posted in Internet, tech, wordpress | Tagged , , | Leave a comment

Simple WordPress Twitter feed code snippet

Sometimes a Twitter plugin is just the right fit for a site, other times it just might be overkill. If all that’s need is a simple list of recent Twitter posts this solution might be the best. The code below can be placed in a functions.php for the current theme or in a separate plugin. The code will automatically change @usernames into links to profiles and #hastags into links for the search page for the tag. It will also convert text links into valid click-able links.
Continue reading

Posted in Internet, tech, wordpress | Tagged , , , | Leave a comment

WordPress 3.4 wp_get_theme – new function for retrieving theme data

Another new addition to 3.4 is the deprecation of the get_theme_data function, this function was used pull data from the header of a theme’s stylesheet. This function was useful for outputting theme data in a repeatable way. The new function wp_get_theme is the replacement for this function. The difference is that the get_theme_data returned data in an array and the data was accessible via array keys, while wp_get_theme returns the data as an object. This has little effect on how the code is used just how to retrieve the data.

Maintaining backwards compatibility is always a top priority when releasing a theme for the public. This code below will accomplish this by testing if the new function exists before running it, and falling back to the old function if it doesn’t. The same variables are used for either way, so they variables can be used regardless of what function is used.
Continue reading

Posted in Featured, tech, wordpress | Tagged , , | Leave a comment

Solving 403 errors with CloudFlare

Recently I’ve switched over to using CloudFlare, for those unfamiliar it’s a proxy caching service. It caches resources from your site in several data centers. When looking over Google Webmaster Tools, I noticed every page it crawled was a 403 error. Not very conducive to having good search rankings.

After some digging the answer finally appeared on the WordPress.org forums. The Bad Behavior plugin was rejecting Google since the crawler was being proxied thru CloudFlare and had the user-agent of Googlebot but was not in the right IP address range. The solution, disable Bad Behavior. Although the plugin had always worked great in reducing the number of spam request, since CloudFlare increases security by blocking bad requests before ever reaching the server, no reason to have Bad Behavior taking up resources as well.

Posted in google, Internet, tech, wordpress | Leave a comment

WordPress Custom Headers Update for 3.4

With the upcoming release of WordPress 3.4 the focus was on improving the overall theme experience. This means changes to the dashboard and changes to the underlying code. One of the improvements was with registering custom headers, the new streamlined process no longer relied on defining constants. Now simply using add_theme_support(‘custom-header’). This alone wasn’t the end of the improvements, the new system also supports flexible height and width custom headers. Passing an array of arguments to the add_theme_support call to achieve all of this rounds out the functionality improvements.

While the improvements are welcome, as a theme author only supporting the very latest version isn’t a good practice. Backwards compatibility should be thought about until a certain point. This code below will use the new way of adding custom headers if the WordPress version is correct, and fallback to the old way of constants if not. This will allow users who are wary of WordPress upgrades, and those who always run the latest and greatest to both benefit. This is done simply by using the php function version_compare and simply comparing the wp_version variable and the version that should be supported, this case 3.4. The block before the else runs if true and the block after runs if false and an older version. The register_default_headers function is still used to give users a choice of included headers.
Continue reading

Posted in Featured, guides, tech, wordpress | 1 Comment