Have you ever wanted to display the caption of a Featured Image in WordPress? I recently had need to do this and figured out a way to accomplish this. When you set the Featured Image for a post in WordPress, you can add additional information for the image: Title, Caption, Alt Text and Description. It… Continue reading Display the caption of a featured image in WordPress
Category: PHP
Adding a Prefixr command to TextMate 2
I was recently looking into how to add a Prefixr command to TextMate 2. For those of you not familiar, Prefixr is a way (created by Jeffrey Way of NetTuts) to take a new-ish CSS property like box-shadow or transform and add all the vendor-specific prefixes automatically. So: transform: rotate(-7deg); becomes: -webkit-transform: rotate(-7deg); -moz-transform: rotate(-7deg);… Continue reading Adding a Prefixr command to TextMate 2
Sitewide settings in CodeIgniter
I recently wanted to set up a system to allow a client to edit sitewide configuration settings on a custom CodeIgniter site. I didn’t want to hardcode it in a configuration file and I wasn’t sure exactly how it would need to be added to in the future. I decided to use a system much… Continue reading Sitewide settings in CodeIgniter
Setting UTF-encoding with a PHP header
Sometimes, I need to write a one-off PHP script to export/import data from a database, for example. Since I am not using any kind of front-end interface, I have found that I sometimes have to specifically set the encoding on the page to avoid any extended character issues with the database. I use: header(‘Content-Type: text/html;… Continue reading Setting UTF-encoding with a PHP header
Protect a cron job from outside access
I recently set up a PHP file that generates an XML-formatted sitemap for a dynamic site and set up a cron job to update the sitemap from time-to-time. I didn’t see any reason to allow outside access to executing the script, so I looked into using .htaccess to restrict access to the script. It turns… Continue reading Protect a cron job from outside access
Custom headers and footers in WordPress
Today I wanted to put a custom post inside of a fancyBox popup. So, I wanted to have access to WordPress’s functions, but I didn’t want the usual header and footer from my main template… I just wanted a very basic page that would fit easily inside of fancyBox. I didn’t realize it, but WordPress… Continue reading Custom headers and footers in WordPress
Installing Composer on Mac OS X Mountain Lion
I recently read about a package management system for PHP on NetTuts called Composer. It looked interesting but I hadn’t had time to play around with it. At work, though, a new project came up that called for using a package from Composer so I needed to figure out how to get it installed and… Continue reading Installing Composer on Mac OS X Mountain Lion
Easy way to pass multiple variables to a CodeIgniter validation callback
I was recently working on a custom form validation callback for my CodeIgniter script. By default, one gets the field that you’re validating available in the callback function. For example, if I have the following form validation rule: $this->form_validation->set_rules(‘discountGlobal’, ‘Global Discount’, ‘trim|integer|max_length[1]|xss_clean|prep_for_form|only_one_global_discount[]’); My custom callback is only_one_global_discount. I am not explicitly passing anything through to… Continue reading Easy way to pass multiple variables to a CodeIgniter validation callback