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

Truncate Post Title

The following snippet controls the maximum title length. Add the following snippet in functions.php. Then use the function customTitle() in the template to output the title in place of the WordPress the_title() method. function customTitle($limit) { $title = get_the_title($post->ID); if(strlen($title) > $limit) { $title = substr($title, 0, $limit) . ‘…’; } echo $title; }

Read More

Display PHP on a Single Page

Allows you to display plugins and such on a single page (replace home with the page you want it to only appear on): if ( is_home() ) { include (‘file.php’); }

Read More

Display Categories

Display Categories wp_list_cats(‘sort_column=name’); Display Categories in Drop-Down Box <form action=”<?php bloginfo(‘url’); ?>/” method=”get”> $select = wp_dropdown_categories(‘show_option_none=Select category&show_count=1&orderby=name&echo=0′); $select = preg_replace(“#<select([^>]*)>#”, “<select$1 onchange=’return this.form.submit()’>”, $select); echo $select; <noscript> <input type=”submit” value=”View” /></noscript> </form>

Read More

Force Perfect JPG Images

WordPress doesn’t use 100% quality for images served on the website, to conserve space and bandwidth. add_filter( ‘jpeg_quality’, ‘smashing_jpeg_quality’ ); function smashing_jpeg_quality() { return 100; } WordPress uses a default quality of 90%. This is fine in most cases; if top-notch image quality is a must on your website (for a portfolio, photography, etc.), modifying […]

Read More

Replace Built-In Scripts By Deregistering Them

If you live on the bleeding edge, you can use versions of scripts other than the built-in ones. Using a newer jQuery version is common (though not necessarily good) practice, which can be done in the following way. function my_scripts_method() { wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, get_template_directory_uri() . ‘/js/jquery-new.js’); wp_enqueue_script( ‘jquery’ ); } add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); […]

Read More

Clear Form Data

function clearForm(form) { // iterate over all of the inputs for the form // element that was passed in $(‘:input’, form).each(function() { var type = this.type; var tag = this.tagName.toLowerCase(); // normalize case // it’s ok to reset the value attr of text inputs, // password inputs, and textareas if (type == ‘text’ || type […]

Read More

Fade In/Out on Hover

$(document).ready(function(){ $(“.thumbs img”).fadeTo(“slow”, 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads $(“.thumbs img”).hover(function(){ $(this).fadeTo(“slow”, 1.0); // This should set the opacity to 100% on hover },function(){ $(this).fadeTo(“slow”, 0.6); // This should set the opacity back to 60% on mouseout }); });

Read More