PHP

WordPress: how to automatically convert custom fields to post tags

Convert your post’s custom fields into tags automatically in WordPress with this nifty script!!!

How to add the excerpt box for pages in WordPress

Here’s how to enable the “excerpt” box for your WordPress pages.

Lesson learned: You can’t access DOM elements within an external iFrame

That’s right, you CAN’T!

PHP – Safely serialize and unserialze arrays

Serializing arrays in PHP is a great way to format their content before storing it in a database. However, if the serialized content has certain characters (such as “;” or “:”)  the resulting string won’t be read correctly by the unserialize() function,  which is a huge bummer. So, here’s a workaround. http://davidwalsh.name/php-serialize-unserialize-issues

Detect IE6 with PHP

Let’s say you want to server-side detect whether a user’s browser is the dreaded IE6 using PHP (instead of on the client side, which is usually done with conditional comments). Here’s how.

How to automatically add tags to WordPress posts

In WordPress, if you need to automatically add tags to a post via a PHP script, the best way to do it is via the wp_set_object_terms() function. There is no handy “wp_insert_tag()” function, or something like that, so look no further.

How to get the ID of the last insert post in WordPress

When programming for WordPress, sometimes you may need to get the ID of the last post that was inserted to the database (à la MySQL’s ‘LAST_INSERT_ID’). Here’s the thing: the wp_insert_post() function returns the newly inserted post’s ID, so you can use it to perform more stuff on the post right away, without having to mess around with any SQL commands to retrieve it. Clever, huh?