Reduce spam by using .htaccess
Adding the following shortcode will let you reduce spam on your WordPress blog by using .htaccess. Simply paste the following lines into your .htaccess file but also make a note that you do make a backup of your .htaccess file before editing it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} .wp-comments-post\.php* RewriteCond %{HTTP_REFERER} !.*yourdomainname.* [OR] RewriteCond %{HTTP_USER_AGENT} ^$ RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L] </IfModule> |
Source: AllGuru.net
Display a thumbnail of any website
Simply paste the code below into your functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
function gk_snap($atts, $content = null) { extract(shortcode_atts(array( "snap" => 'http://s.wordpress.com/mshots/v1/', "url" => 'http://www.geekeries.fr', "alt" => 'Mon image', "w" => '400', // largeur "h" => '300' // hauteur ), $atts)); $img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>'; return $img; } add_shortcode("snap", "gk_snap");unction gk_snap($atts, $content = null) { extract(shortcode_atts(array( "snap" => 'http://s.wordpress.com/mshots/v1/', "url" => 'http://www.geekeries.fr', "alt" => 'Mon image', "w" => '400', // largeur "h" => '300' // hauteur ), $atts)); $img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>'; return $img; } add_shortcode("snap", "gk_snap"); |
Once done, you can use the snap shortcode:
1 |
[snap url="http://www.geekeries.fr/publicites/" alt="Ma description" w="400" h="300"] |
Source: Geekeries.fr
Easily remove weird characters from your WordPress database
The shortcode will remove the weird characters from your WordPress database. All you have to do is simply run the following SQL query on your nWordPress database via the command line client or PhpMyAdmin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '“'); UPDATE wp_posts SET post_content = REPLACE(post_content, 'â€', '”'); UPDATE wp_posts SET post_content = REPLACE(post_content, '’', '’'); UPDATE wp_posts SET post_content = REPLACE(post_content, '‘', '‘'); UPDATE wp_posts SET post_content = REPLACE(post_content, '—', '–'); UPDATE wp_posts SET post_content = REPLACE(post_content, '–', '—'); UPDATE wp_posts SET post_content = REPLACE(post_content, '•', '-'); UPDATE wp_posts SET post_content = REPLACE(post_content, '…', '…'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, '“', '“'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, 'â€', '”'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, '’', '’'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, '‘', '‘'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, '—', '–'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, '–', '—'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, '•', '-'); UPDATE wp_comments SET comment_content = REPLACE(comment_content, '…', '…'); |
Source: Jeff Starr
How to change WordPress editor font
Adding the following shortcode to your functions.php file will let you change the default WordPress editor font.
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 } |
Source: DevPress
Removing the “read more” jump
Adding the shortcode into your functions.php file will remove the “read more” link from your blog which will automatically takes you to the article page.
1 2 3 4 5 6 7 |
function wdc_no_more_jumping($post) { return '<a href="'.get_permalink($post->ID).'" class="read-more">'.'Continue Reading'.'</a>'; } add_filter('excerpt_more', 'wdc_no_more_jumping'); |
Source: Alex Denning
Quick maintenance mode
Paste the following code into your functions.php file and you will be able to easily implement a maintenance mode on your WordPress blog.
1 2 3 4 5 6 7 8 9 10 11 |
function wpr_maintenance_mode() { if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) { wp_die('Maintenance, please come back soon.'); } } add_action('get_header', 'wpr_maintenance_mode'); |
Source: Skyje
Disable theme changing
Simply paste the code in your functions.php file to disable theme changing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
add_action('admin_init', 'slt_lock_theme'); function slt_lock_theme() { global $submenu, $userdata; get_currentuserinfo(); if ($userdata->ID != 1) { unset($submenu['themes.php'][5]); unset($submenu['themes.php'][15]); } } |
Source: Steve Taylor
Redirect feeds to a single format
Adding the following shortcode to your .htaccess file will let you direct all your feeds to a single format.
1 2 3 4 5 6 7 |
<IfModule mod_alias.c> RedirectMatch 301 /feed/(atom|rdf|rss|rss2)/?$ http://example.com/feed/ RedirectMatch 301 /comments/feed/(atom|rdf|rss|rss2)/?$ http://example.com/comments/feed/ </IfModule> |
Source: Digging into WordPress
Simpler WordPress login url
Adding the following code to your .htaccess file will let you have the simpler WordPress login url.
1 |
RewriteRule ^login$ http://website.com/wp-login.php [NC,L] |
Source: Kevin Chard
How to modify size of embedded videos
On adding the following shortcode to your theme’s functions.php file will let you modify the size of embedded videos.
1 2 3 4 5 6 7 8 9 10 11 |
function mycustom_embed_defaults($embed_size){ $embed_size['width'] = 586; // Adjust values to your needs $embed_size['height'] = 500; return $embed_size; } add_filter('embed_defaults', 'mycustom_embed_defaults'); |
Source: Shailan
Photo Credit: Flickr/hackNY.org