WordPress Snippets

As a WordPress developer I have collected / created / curated many snippets that I’ve used in my projects. I hope you find them useful.   General HTML / WordPress tags Get your template’s directory <link href=”<?php echo get_template_directory_uri(); ?>/style.css” rel=”stylesheet” media=”screen”>   Check if this is the home page <?php if (is_home()) { … …

Installing MongoDB/PHP Driver on CentOS 6

Since the module is not included with the default PHP installation, you have to download it from the official repository: cd mkdir mongo-php-driver cd mongo-php-driver curl https://codeload.github.com/mongodb/mongo-php-driver/zip/master > mongo-php-driver-master.zip Unzip it unzip mongo-php-driver-master.zip cd mongo-php-driver-master You need phpize to build the module. You can install it from the remi repository: wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm rpm -Uvh remi-release-6.rpm yum –enablerepo=remi install …

Installing the PHP/MongoDB extension on Mac OSX 10.8

Installing PHP/MongoDB extension is a two steps task on OSX: Install the autoconf tool required for compiling the extension Install the Mongo extension You have to install autoconf in order to avoid the following error: Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. ERROR: `phpize’ failed …

Add a Thumbnail to Admin Post Columns in WordPress

Here is a snippet to add 64×64 images to the Admin Post Columns in WordPress. Having thumbnails may result extremely helpful, specially if you have hundreds of posts. You have to copy and paste the following code into the functions.php file of your theme. function posts_columns($defaults){ $defaults[‘the_post_thumbs’] = __(‘Thumbs’); return $defaults; } function posts_custom_columns($column_name, $id){ …

IIS tips and tricks

Running multiple versions of the .NET framework in IIS When you install a new .NET framework in your IIS server some applications can stop working showing you the following error: Server Application Unavailable   In the event viewer you will find this: It is not possible to run two different versions of ASP.NET in the …