Snippets

38 posts

Exclude Certain Folders from htaccess Rewrite Rules

If you have an application or CMS running, you might have SEO url’s enabled through .htaccess rewrites. Now installing a second application in a subfolder on the same domain can cause 404 errors. This is because all subfolders follow the rules specified in the root htaccess file. To prevent the errors, […]

Scaleable Full Screen Background Image with CSS3

With the background-size property in CSS3, we can get a full page scaleable background image. Here’s the CSS code: html { background: url(images/background.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } Background image is centered, automatically resized according to browser size, and retains the aspect […]

Search and Delete Unused Post Tags in WordPress

Here are three SQL queries to find and safely delete all unused tags from your WordPress blog database. The below command will show you all the unused tags in the database. SELECT * FROM wp_terms wterms INNER JOIN wp_term_taxonomy wttax ON wterms.term_id = wttax.term_id WHERE wttax.taxonomy = ‘post_tag’ AND wttax.count […]

Display Simple Maintenance Mode Message to Non-Admins

Here’s a snippet to display a simple maintenance mode message to all non-admin visitors of your WordPress blog, while you carry on your tasks in the back-end. function wp_maintenance_mode() { if ( !is_user_logged_in() || !current_user_can( ‘manage_options’ ) ) { wp_die(‘Site is undergoing maintenance at the moment, please come back after […]

Smooth Scroll to Page Top without an Anchor

This little jQuery snippet adds a smooth scroll-to-top effect on a page.  Unlike some other methods, this doesn’t need an anchor for the scroll effect to work on a page. You can change the scroll speed and “scroll up to” position in this script. $(document).ready(function(){ $(“.top”).click(function(e){ e.preventDefault(); $(“body,html”).animate({ scrollTop: 0 // Top […]