While PHP namespaces allow you to refer to a function in file without using the fully qualified name, there is a catch when adding a WordPress hook or filter. The PHP __NAMESPACE__ magic constant can be helpful in this situation.
Code to add a custom column to the WP Admin Posts listing page.
When using Scriptless Social Sharing, you may want to add a site wide hashtag to all of your tweets. This is the code you can use to do that.
When creating new posts for a video demonstration, I wanted to display a consistent date. While my first thought was to reset my system clock, this snippet overrides the date when the post is first created, which worked for me.
I like to use the Scriptless Social Sharing WordPress plugin to add Share buttons to my blog posts. Recently I had a client notice that because the Email Share button has target=”_blank” in the HTML markup, it opens a new tab when clicked. This is great behavior if you’re using web based email (e.g. Gmail), however if you’re using an email application on your computer, you end up with a blank tab. This code removes target blank from the email share link.
I often find it helpful to add a label to the Featured Image area in the WordPress admin. By guiding clients to upload the appropriate sized image, it lets me avoid them being surprised by WordPress cropping their image in an unexpected way.
When it comes to adding social sharing buttons (e.g. “Share on Facebook”), I’m a big fan of Scriptless Social Sharing by Robin Cornett. The one thing I like to do when using it is add UTM parameters to the links that are shared. Here is the snippet I use to add UTM parameters to my URLs that are being shared.
As a WordPress developer it is a painful (and all too familiar) feeling of angst, when I find a plugin that does almost exactly what I want but the author has left no way for me to modify the behavior without changing their code. Don’t Hack Core (or plugins) A popular refrain in WordPress developer […]
Recently, I wanted to add content to each item in the RSS feed on a WordPress site. This could be something like: Hire Sal If you enjoyed this article, have you considered hiring Sal to help with your project? To add this, we can leverage the WordPress filter the_content_feed. The code would look something like […]