Put this line in functions.php of your theme
add_filter( 'show_admin_bar', '__return_false' );
Put this line in functions.php of your theme
add_filter( 'show_admin_bar', '__return_false' );
This is for people who need to protect their blog with username and password that can be easyly set from the WordPress backend.
1. Go to Users → Authors & Users sub-panel.
2. Add a new user in the Add New User section. This login will be used to access your WordPress by other user. Or go to Settings → General → Membership and check “Anyone can register”.
3. Add the following lines to your WordPress Theme’s template functions.php file (For example, functions.php file for a Theme named “default” would probably reside in the directory wp-content/themes/default/functions.php) or create it as a Plugin by filling the additional Standard Plugin Information:
<?php
function password_protected() {
if ( !is_user_logged_in() )
auth_redirect();
}
add_action('login_head', 'rsd_link');
add_action('login_head', 'wlwmanifest_link');
add_action('template_redirect', 'password_protected');
add_action('do_feed', 'password_protected');
?>
4. Go to Settings → Discussion sub-panel. Under Default article settings, uncheck “Attempt to notify any blogs linked to from the article (slows down posting.)”.
5. Finally, go to Settings → Privacy and set “Blog Visibility to I would like to block search engines, but allow normal visitors”. Click Save Changes.
Now visitors will be asked to log in using WordPress login form to view your WordPress blog / site. This is very suitable for someone that wanted privacy or owned a private password protected WordPress blog / site.
It can be used with the plugin wassup for visitors tracking.
This code will add class for first and last item in WordPress custom menus:
//This add class first and last to the custom menus
function add_first_and_last($output) {
$output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1);
$output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item'));
return $output;
}
add_filter('wp_nav_menu', 'add_first_and_last');