Check if page or post contains a term that is a descendant of another term

This function is pretty self-explanatory. Will return true if the page or post contains a term that is the descendant of $parent_term and false if it doesn’t. $parent_term accepts a term id or object. $post_id is optional, if one is not specified it will attempt to get the current page or post ID via WordPress’s built-in get_the_ID function.

Unzip a compressed sql backup and import it into a database

Figured I’d put a Bash script up here since I haven’t posted any before. This is a small function that I keep inside of my .bashrc file to unzip an sql database that has been exported into a .sql.gz file (or any other sort of compressed file extension) and import it into my local database.

It takes 2 arguments, the first one is the exported file and the second is the database that you would like to import it to. Use it like so:

 

Pause Bootstrap’s carousel when fancyBox is loaded and play it again when fancyBox is closed

Sweet and simple!

Note: Tested using Bootstrap v3.3.5 and fancyBox v2.1.5

Get window size break-point in JavaScript

Here’s a quick and easy JavaScript code snippet that will return your window size break-point. This can be handy when writing custom JavaScript code for a mobile responsive website.

The break-points are set to the default sizes used in Bootstrap but can be changed easily if needed. It will return one of the following: xs, sm, md, or lg.

Simple function to show which template file a page is using in WordPress

When working on a WordPress site, more often than not you will run into a situation where you will need to find out which template file a page is using. Here’s a small function that you can throw into your theme’s functions.php file that will add an item to the admin bar telling you which template file the current page is using. You can also hover over it to get the full URL to that template file.

The item will only show up for administrators and it will only show up on the site’s front-end. Therefore you can just throw this code in there and leave it there!