PHP

Relating Posts, Pages, and Custom Post Types in WordPress

I received a question from a fellow WordPress designer/developer recently on how I was able to bring content from related pages and posts into any page, post, or custom post type. "I like the way you pull in posts featured images and also page featured images on the bottom of pages.  It keeps the site hoping.  I wasn't able to find a plugin that would pull in featured images on both posts and pages and all of them seemed to be recent posts or random.  And then I tried to use categories in post … [Read more...]

Style Nth Word In a Phrase

The CSS Scenario Recently my graphic designer used a nice styling on a client's webpage headlines--all words in the headline were one color and the last word was a different color. It adds for a nice effect I think. Of course, as the developer I'm the one who has the responsibility to bring that to life. After a few quick searches on Google for phrases like, CSS Style Nth Word CSS style last word, CSS style first word php style nth word, php style first word, php get first … [Read more...]

Convert MS Access Date to Unix Timestamp to MySQL Timestamp

I came across a problem today where I needed to convert a date in an MS Access Database to a MySQL timestamp using PHP. The solution was pretty easy, but took some thinking through. Here is the answer to save you some time if you need it. Get the date from your MS Access database. If you're using PHP to do this, you'll likely use the odbc_exec($connection, $query) function and the odbc_fetch_array() function. Convert the MS Access date format into a UNIX Timestamp using PHP's strtotime() … [Read more...]

WordPress Super Cache and Setting Cookies

WP Super Cache and PHP Cookies Don't Mix Website Development Challenge: Setting PHP Cookies While Using WP Super Cache Solution: Set the cookie using Javascript When I created the First Touch Referral Tracking plugin, it seemed like it should be pretty straight forward: check for a cookie with a referrer and set a cookie with the referrer if there's not one. Then, simply grab the cookie whenever it's needed and calculate a referral coupon code. So, I wrote the code using PHP's setcookie() … [Read more...]