NO Follow WordPress Tag Cloud
The following snippet will result in no following WordPress Tag cloud. All you have to do is to add the snippet to your theme’s functions.php.
1 2 3 4 5 6 7 |
function add_nofollow_tag($sLink) { return str_replace('<a href=', '<a rel="nofollow" href=', $sLink); } add_filter('wp_tag_cloud', 'add_nofollow_tag'); |
Expire Protected Post Cookie With Session
You need to set the time of 0 in setcookie() to your theme’s functions.php template. Setting the time will let you forces the cookie to expire the session.
1 2 3 4 5 6 7 8 9 10 11 |
add_action( 'wp', 'post_pw_sess_expire' ); function post_pw_sess_expire() { if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ) // Setting a time of 0 in setcookie() forces the cookie to expire with the session setcookie('wp-postpass_' . COOKIEHASH, '', 0, COOKIEPATH); } |
Source: Drew Jaynes
Display avatar for currently logged in user with get_avatar
The snippet will let you display the currently logged in users avatar in your theme.
1 2 3 4 5 6 7 8 9 |
<?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 64 ); ?> |
Prevent access to wp-admin
Adding this snippet to your functions.php will redirect subscribers away from wp-admin to the home page.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if ( is_user_logged_in() && is_admin() ) { global $current_user; get_currentuserinfo(); $user_info = get_userdata($current_user->ID); if ( $user_info->wp_user_level == 0 ) { header( 'Location: '.get_bloginfo('home').'/wp-login.php?redirect='.get_bloginfo('home').'/wp-admin/' ); } } |
Source: Flowdrops.com
Hide login errors
The code will disable the login errors that are displayed to users.
1 |
add_filter('login_errors', create_function('$a', "return null;")); |
Page excerpt
The snippet will add excerpts for pages. All you require is to place the following code in your themes functions.php file and you are done.
1 |
add_post_type_support( 'page', 'excerpt' ); |
Reset your password
This would be a biggest nightmare for you if not able to reset your password especially when you can’t use the “forgot password” function. Insert this snippet into a phpMyAdmin Sql-window.
1 |
UPDATE `wp_users` SET `user_pass` = MD5('NEW_PASSWORD') WHERE `wp_users`.`user_login` =`YOUR_USER_NAME` LIMIT 1; |
Image Custom Field
If you want to call the custom field for an image source, then use the following snippet.
1 2 3 4 5 6 7 8 9 10 11 |
<?php $image = get_post_meta($post->ID, 'image', TRUE); ?> <?php if($image) { ?> <img src=" <?php echo $image; ?> " alt="Alt Text" /> <?php } ?> |
Add a Dashboard Widget
As soon as you login into your WordPress Dashboard, the first thing you will notice that it has been filed with number of widgets. Using this code will allow you to add your own widgets, just add this code to functions.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php function your_dashboard_widget() { ?> <h3>Hello Wordpress user!</h3> <p>Fill this with HTML or PHP.</p> <?php }; function add_your_dashboard_widget() { wp_add_dashboard_widget( 'your_dashboard_widget', __( 'Widget Title!' ), 'your_dashboard_widget' ); } add_action('wp_dashboard_setup', 'add_your_dashboard_widget' ); ?> |
Photo Credit: Flickr/hackNY.org