5 Simple WordPress Tricks

5 Simple Wordpress Tricks

At JJ Web Services, we provide information and guidance you need to run a successful online enterprise. WordPress is such an amazing platform that you can do almost anything with it.

We have been working with WordPress for a very long time now continuing to discover more tips and tricks as WordPress progresses.

1. FeedBurner Redirection
FeedBurner is used on almost every blog. You can try this:
add_action( ‘template_redirect’ , ‘smashing_rss_redirect’);
function smashing_rss_redirect() {
if ( is_feed() AND !preg_match( ‘/feedburner|feedvalidator/i’, $_SERVER[‘HTTP_USER_AGENT’] ) ){
header( ‘Location: http://feeds.feedburner.com/my_smashing_feed’ );
header( ‘HTTP/1.1 302 Temporary Redirect’ );
}
}

2. Use unlimited Built-In Scripts
You already know that with wp_enqueue_script() and wp_enqueue_style(), you can include styles and scripts easily. However, did you know that a lot of scripts are already built in? jQuery, many elements of jQuery UI, jQuery Form, SWF Object, Tiny MCE, Jcrop and Thickbox are just some the better known ones.

3. Try replacing Built-In Scripts
You can also use versions of scripts other than the built-in ones. Using a newer jQuery version is common, but may not necessarily be a good practice. It is recommended only when encountering compatibility issues, such as a plugin that specifically requires it.
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’);

4. 100 percent Spectacular and perfect JPG Images
WordPress does not use 100 percent quality for images in order to save space and bandwidth. WordPress uses a default of 90 percent for images, which is not bad at all as most of the times, you will not be able to even make out the difference. If you want a perfect image, you will have to modify the value. Here is how:
add_filter( ‘jpeg_quality’, ‘smashing_jpeg_quality’ );
function smashing_jpeg_quality() {
return 100;
}

5. Setting Up Sessions In WordPress
Sessions work fabulously for storing information between pages and are widely used on websites. Using the following method, you can start a session on all pages before any output.
add_action( ‘init’, ‘smashing_session_start’ );
function smashing_session_start() {
if ( !session_id() ) {
session_start();
}