Remove Paragraph Tags From Around Images

function filter_ptags_on_images($content){ return preg_replace(‘/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU’, ‘\1\2\3’, $content); } add_filter(‘the_content’, ‘filter_ptags_on_images’);

Read More

Kitchen Sink 2

Custom CSS for the login page Create wp-login.css in your theme folder function wpfme_loginCSS() { echo ”; } add_action(‘login_head’, ‘wpfme_loginCSS’); function wpfme_has_sidebar($classes) { if (is_active_sidebar(‘sidebar’)) { // add ‘class-name’ to the $classes array $classes[] = ‘has_sidebar’; } // return the $classes array return $classes; } add_filter(‘body_class’,’wpfme_has_sidebar’); Call Googles HTML5 Shim, but only for users on […]

Read More

Create a PDF viewer Shortcode

If you’re using PDF files on your WordPress blog, it could be very cool to give your users the chance to open them using Google Docs. The following recipe will show you how you can do that. The first step is to paste the following code into your functions.php file: function pdflink($attr, $content) { return […]

Read More

Allow upload of more file types

WordPress uploader won’t let you upload some filetypes. If you need to upload other file types this will allow you to do it. Paste the code in functions.php file. If needed, you can add more file types by adding them on line 4, separated by a pipe (|) <?php function addUploadMimes($mimes) { $mimes = array_merge($mimes, […]

Read More

Detect mobile visitors

First have to get the code from detectmobilebrowsers.mobi and upload it to your theme directory. Once done, simply open your header.php file and place the following at the top of the file. Don’t forget to edit line 5 according to the page where you’d like to redirect mobile users. include(‘mobile_device_detect.php’); $mobile = mobile_device_detect(); if ($mobile==true) […]

Read More

Show the number of results found

Search results pages are important for a website UX, so it should be pretty useful to the user. Problem is many search results page give no information about how many pages on what I’m searching for there are in a website. Thanks to the following line of code in your search.php file, you’ll be able […]

Read More

Change the post auto-save interval

The auto-save feature is your safety net: automagically WordPress saves your work, so you don’t have to worry about it in the event of a browser crash or a blackout. For some users though, the 1 minute default could be a little too much and they keep interrupting their work to push the save button. […]

Read More

Move Your WP-Content Folders

The wp-content folder contains your themes, plugins and uploads. Certain plugins, such as caching plugins, also use the wp-content folder to store data. Due to this, the wp-content folder is frequently a target for hackers, particularly those that insert malware into your theme files. You can make it difficult for people to find your wp-content […]

Read More