Add categories and tags support to custom post types in WordPress

Adding a custom post type in WordPress is pretty easy and while it can be done and managed via external plugins, it’s pretty easy to do it by adding a little code in the functions.php file of your theme. All we need to do is take advantage of the “register_post_type” method that’s provided by wp. You can see more details and all the params on the Codex.

Here is a simple example that creates a custom post type named “project”:

By default, this new custom post type doesn’t has the ability to use taxonomies (categories, tags, or any other custom taxonomies you might need), but that can be easily added. Simply add ‘taxonomies’ => array(‘category’, ‘post_tag’) to the $args variable then initialize the new taxonomies. The code will look like so:

If anyone knows an easier way (without using a plugin) of achieving this, please use the comments section below!

How To: Mac OS X and Midnight Commander “Insert” Key fix

After moving from Linux (Ubuntu) to OS X, one of the most annoying things i’ve ran into, was not having the Insert Key work as it was intended inside Midnight Commander. In Linux, while in mc, you can hit the Ins key to select or tag an individual file or folder. This is very useful when you want to cleanup and folder or move/copy stuff around. While there is the Ctrl + T shortcut (i’ve found that via:, it’s pretty annoying to use it when the muscle memory keeps going to the Ins key.

I was using BetterTouchTool to get the back/forward mouse buttons working on Yosemite, so i’ve looked around if i can setup a keyboard shortcut. And you can: I’ve setup under “Keyboard” options, an entry for iTerm (my Terminal app of choice on the mac), if the Ins key is pressed to trigger the Ctrl + T shortcut. Works like a charm in mc 🙂
Screen Shot 2015-01-27 at 5.41.10 PM

How to: Create a new wine prefix or bottle

When running Windows apps under Linux via wine, it’s always a good idea to have each app in it’s own sandbox or wine bottle if you will. After you get an app running with wine, you can store the bottle and grab it from the cellar when you need it.

A wine bottle, is similar to a clean windows install. When creating it, you can specify if the architecture should be 32 or 64bit, which basically emulates a 32 or 64bit machine with windows. You can also keep for each bottle individual settings via winecfg.

Here is how you can create one:

winearch=win32 WINEPREFIX="/opt/cellar/civ5" winecfg

This will create a clean 32bit wine prefix, stores everything in the “/opt/cellar/civ5” folder and opens the winecfg app for that prefix. Note that in order to use that prefix, you must always make sure you specify it:

winearch=win32 WINEPREFIX="/opt/cellar/civ5" wine notepad

I keep all my wine bottles on an external HDD mounted under /opt/cellar. As long as the correct wine version is installed on each machine for that bottle, i can take the HDD and use the apps on any Linux machine.

How To: Delete ALL older kernels

If you are using Ubuntu, there is a good chance you get kernel upgrades once in a while. There is no reason, after you’ve booted the new kernel and verified that everything is working properly, why you should not delete all older kernels. This will free up a bit of that root partition. If you are like me and mount / on a small SSD partition, every MB counts. For me the modules for each kernel version are around 160MB.

Here is a CLI one-liner to delete all order kernels, leaving only the latest on the system:

sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')

Fix VMware Workstation Module compile error on Ubuntu/Debian Linux

# Become root
sudo -i

# Do a couple of pre-requisites
apt-get install build-essential
ln -s /usr/src/linux-headers-$(uname -r)/include/generated/uapi/linux/version.h /usr/src/linux-headers-$(uname -r)/include/linux/version.h

# Extract each of the VMware module packages

cd /usr/lib/vmware/modules/source
for file in *
tar xvf $file

# Fetch and apply patches required for this release...
patch -p0 < vmci.linux-3-8.patch

# Put the VMware module source packages back together again
for file in *-only
tar cvf `basename $file -only`.tar $file
rm -rf *-only

# Tell VMware to rebuild the modules - can also just run the command "vmware" as root
vmware-modconfig --console --install-all

Magento tip : Image Upload HTTP error

There are a few possible causes including problems with mod_security.. however, if you are working behind a .htaccess/.htpasswd files to protect your site, you need to allow POST calls to go through; they’re being blocked b/c the AJAX call doesn’t know to use your cookie.


Require valid-user

to your .htaccess and you should be good to go.

Real time folder monitoring in CLI Linux

I needed to see the changes to a folder in realtime and after a bit of looking around, i’ve found this solution:

 watch -d -n 1 'df; echo " "; echo "Local folder updates:"; ls -FIAt;'

If you want to refresh at longer intervals (not 1s as it is now) all you have to do is change the value of the -n parameter as so:

 watch -d -n 10 'df; echo " "; echo "Local folder updates:"; ls -FIAt;'

This will show you the changes to the current folder every 10s.