Tag: PHP




How to Conditionally Enqueue a JavaScript File in WordPress

Enqueuing is the WordPress way to add a stylesheet or JavaScript file on a page. We already published a Quick Guide about including your JavaScript in WordPress. This time, though, we’re adding an extra wrinkle: how do you only enqueue a JavaScript file on certain pages of your WordPress site. That’s the focus of this here Quick Guide.


A Code Snippet to Fix WooCommerce 3.0 Lightboxes

I truly love WooCommerce, but there’s one thing I don’t love about it: breaking changes. Working mostly in WordPress, breaking changes generally feel like something scary and challenging that I expect people in other environments to have to deal with—a bit like, say, cobras. The exception is WooCommerce, which brings the cobras right into my house.



Get a WordPress Image’s Attachment ID from its URL with a PHP Function from Pippin Williamson

pippin's plugins | retrieve image id from url
EDIT: As the comments below have pointed out, WordPress in later versions contains the attachment_url_to_postid() function, which is designed to do the job of the code below. However, on at least one project I’ve worked on (a WordPress multisite), WordPress’s function didn’t work and Pippin’s did. I’d try the WordPress function first and Pippin’s as a fallback.

You know who’s really great? Pippin Williamson.


WordPress Custom Taxonomies: How and Why to Create Them

Organizing your content is one of the core features of WordPress content-management system like WordPress. As such, WordPress creates what are called “taxonomies” to help you keep your content easy to find for both your and your visitors. Today we’re focused on why and how to make a WordPress custom taxonomy.



What WordPress Teaches Us About Software Ecosystems

WordPress is, without a doubt, one of the most successful pieces of software of all time. Sure, Microsoft’s Office and Windows are both more influential. Apple’s iOS is huge, as is Google’s Android. Linux is no chump either. But WordPress is relevant to all those platforms and more. And it has about the same name recognition to boot. If people can name a single piece of web infrastructure technology today, there’s a good chance of WordPress being the one they know. (Not counting Facebook as infrastructure.)