I’ve just released a new PHP library for simplifying Ajax requests in WordPress plugins and themes. It’s called WP Ajax Helper, and you can find it on GitHub and Packagist.
Continue reading
php
Get the Attachment ID from an Image URL in WordPress
I recently needed a way to get the ID of a WordPress image attachment, but I only had the image URL to work with. The problem was complicated by the fact that the image URL could be a thumbnail of the original image attachment, i.e. one of the auto-generated post thumbnail image sizes. Continue reading
Add Post Categories to the Body Class in WordPress
Sometimes you may find yourself needing to style a particular post differently, based on the category that it’s in. Here’s a little function that will add each of a post’s categories to the body class of the single post page (assuming your theme uses the body_class template tag):
Continue reading