How To Automatically Obfuscate Email Addresses
You must be aware that the spam bots keeps on monitoring the internet in an urge to find emails to spam. No doubt that you don’t want to show up your email for such a purpose that spam bots come and collect your email address for spamming purpose. You can avoid this by simply using the snippet below.
1 |
<?php antispambot('name@email.com',1 ) ?> |
Snippet Source/Credit: WordPress Codex
How To Automatically Prefetch Next Pages On Your WordPress Blog
Using the following snippet will let you automatically prefetch next pages on your WordPress blog. All you have to do is to simply paste the snippet in your theme’s header.php file and you are done.
1 2 3 4 5 6 7 |
<?php if (is_archive() && ($paged > 1) && ($paged < $wp_query->max_num_pages)) { ?> <link rel="prefetch" href="<?php echo get_next_posts_page_link(); ?>"> <link rel="prerender" href="<?php echo get_next_posts_page_link(); ?>"> <?php } ?> |
Snippet Source/Credit: Bernd
How to change WordPress editor font
You might think of changing your WordPress visual editor font for one-to-many times, but you did wonder that how it can be done. Well, answer is simple, all you have to do is use the snippet below and you are able to change the font as per your wish.
1 2 3 4 5 6 7 8 9 |
add_action( 'admin_head-post.php', 'devpress_fix_html_editor_font' ); add_action( 'admin_head-post-new.php', 'devpress_fix_html_editor_font' ); function devpress_fix_html_editor_font() { ?> <style type="text/css">#editorcontainer #content, #wp_mce_fullscreen { font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; }</style> <?php } |
Snippet Source/Credit: DevPress
How to count retweets in full text
Adding the following snippet in your theme’s functions.php file, you will be able to count retweets in full text.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function tweetCount($url) { $content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url); $element = new SimpleXmlElement($content); $retweets = $element->story->url_count; if($retweets){ return $retweets; } else { return 0; } } |
Once saved copy and paste the following lines of snippets in your theme’s single.php file:
1 2 3 |
$rt = tweetCount(get_permalink()); echo "Retweeted ".$rt." times."; |
Snippet Source/Credit: WPRecipes
How to count your blogroll links
You do wish one-to-many times to make a count of blogroll links which you are having on your website. Well, if yes, all you have to do is to simply paste the following snippet in your theme’s file and you are done.
1 2 3 4 5 6 7 8 9 |
<?php $numlinks = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); if (0 < $numlinks) $numlinks = number_format($numlinks); echo $numlinks; ?> |
Snippet Source/Credit: Jeff Starr
How to define a minimum word count per post
Sometimes you wish to define a minimum word count per post for different authors. Well, this can be possible by simply copying and pasting the snippet to your theme’s functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function minWord($content){ global $post; $num = 100; //set this to the minimum number of words $content = $post->post_content; if (str_word_count($content) < $num) wp_die( __('Error: your post is below the minimum word count.') ); } add_action('publish_post', 'minWord'); |
Snippet Source/Credit: Pippin Williamson
How To Disable Plugins Update In Your WordPress Blog
By default, WordPress always keeps an eye that whether there is any new plugin update is available of not and if it is available, it will notifies you. If in case, such a thing irritates you, then pasting the following snippet will let you be able to disable plugins update in your WordPress blog.
1 2 3 |
remove_action( 'load-update-core.php', 'wp_update_plugins' ); add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) ); |
Snippet Source/Credit: WP Snippets