As WordPress upgraded with its latest and best version that is WordPress 3.0 Beta or WordPress 3.0 , we not should know more about the capabilities added to its new versions and for this, we should jump into deep in it. So, we have gathered some awesome 40 Most-Wanted WordPress Hacks that would make your WordPress based Blogging easy and as what you want.
Note that these Hacks are not made according an Individual Purpose, you are free to change to get your desirable results.
![]()
1.Protect wp-config File using .htaccess
.htaccess is very powerful file which can be used for various purpose. As all WordPressers know how much important is wp-config.php file. And its protection is must must. The file is located in your WordPress Directory, and if not create one and paste the following code into it.
<files wp-config.php> order allow,deny deny from all </files>
2.Embed Adsense anywhere on your posts
Its somewhat for the Beginner Bloggers to put Adsense Ads at their desired position. To place your Adsense ads anywhere in your blog, paste the following code in your Theme’s function.php file.
function showads() {
return '
Your Adsense Code Here
';
}
add_shortcode('adsense', 'showads');
Now, save the functions file and now put the following code anywhere you want to display the Adsense Ad.
[adsense]
You can also place any other Ad according to you.
3. Simple Way to Remove Your WordPress Version

As all the WordPress Users may be aware that WordPress automatically displays the version you are using in the head of your blog files. But some of you may not want these notifications. Simple paste this in your theme”s functions.php file.
remove_action('wp_head', 'wp_generator');
4. Display Related Articles with Thumbnails

Most of the WordPress Users may be using Plugins to display related Articles with Thumbnails. Alternatively, we can also use some code to display Related Posts with Thumbnails.
<?php
$original_post = $post;
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo '<h2>Related Posts</h2>';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>4,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo "<ul>";
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><img src="width="40" height="40" <?php echo get_post_meta($post->ID, "post-img", true); ?>/><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;
echo "</ul>";
}
}
$post = $original_post;
wp_reset_query();
?>
What you have to is paste the above code into your single.php file after the_content(). You can change the value of number of posts to show by changing the default value 4 bolded above on 10th line.
5. Display Ads in RSS Feeds
By Default, the RSS feeds comes with list of your Articles either with excerpts or full Article. You can Insert your Desired Content/ Ads in RSS Feeds using the code below.Paste the code in functions.php
function insertRss($content) {
if(is_feed()){
$content = 'text before content'.$content.'Ad Code Goes Here';
}
return $content;
}
add_filter('the_content', 'insertRss');
6. Redirect Your Blog Using 301 Redirection
Using the below code, you will be able to redirect your blog”s users to custom URL, just paste this one line code in your theme”s functions.php .Only Replace the URL (http://www.smashingeeks.com) with your desired URL.
<?php wp_redirect('http://www.smashingeeks.com', 301); ?>
7. Display Content to Registered Users Only
Custom content of your blog can be made protected easily if you want to display it only to registered users of your blog only. Paste this code in your functions.php file.
function member_check_shortcode($atts, $content = null) {
if (is_user_logged_in() && !is_null($content) && !is_feed()) {
return $content;
} else {
return 'Sorry, this part is only available to our members. Click here to become a member!';
}
add_shortcode('member', 'member_check_shortcode');
Then place this snippet where you want your content to be protected.
[member] This text will be displayed only to registered users. [/member]
8. Display Your Blogs Post Statics

This is a unique code which allows you to display your Total Number of Posts, Total Comments and Average Comments Per Post in your blog.
<?php $count_posts = wp_count_posts(); $posts = $count_posts->publish; $count_comments = get_comment_count(); $comments = $count_comments['approved']; echo "There's a total of ".$comments." comments on my blog, with an average ".round($comments/$posts)." comments per post."; ?>
Place the code anywhere in your blog where you want to display the statics of your blog.
9. Create Under Construction Page for your Blog

There are several methods to create Under Construction/ Coming Soon/ Maintenance Mode Page for your blog. If you want to add extra page for above of them, use the code in your .htaccess file.
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123.123.123.123
RewriteRule $ /maintenance.html [R=302,L]
Replace the 123.123.123.123 with your IP Address and create a Page named maintenance.html and place it in your WordPress Directory.
10. Catch First Image from your Post
Its seen in most blogs that first Images from post are shown as Thumbnails on the Blog”s Homepage. To do this, copy the function below to your functions.php file.
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=['"]([^'"]+)['"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Default Image
$first_img = "/images/default.jpg";
}
return $first_img;
}
To get this Image in your blog, place the below code wherever you want to display the Image.
<?php echo catch_that_image() ?>
Pingback: 20 Most Wanted Wordpress Hacks for Your Blog
Pingback: 20 Most Wanted WordPress Hacks for Your Blog | Best Web Gallery - Flash Gallery - CSS Gallery - Web Design Inspiration - CSS Web Gallery - Designing Gallery