This piece of code is trivial and very useful for development of custom sites and cms.
add to functions.php
add_filter('logout_url', 'projectivemotion_logout_home', 10, 2);
function projectivemotion_logout_home($logouturl, $redir)
{
$redir = get_option('siteurl');
return $logouturl . '&redirect_to=' . urlencode($redir);
}
Enjoy! Happy Coding!
- Amado Martinez / Projectivemotion Web Development
My name is Amado Martinez. I'm a 23 year old programmer living in Reynosa, Mexico. I specialize in website systems. I'm not a frequent blogger, but I hope that you find my web development tips helpful and perhaps even AWESOME! Thanks for visiting :)
How about changing the core file (wp-includes/general-template.php) to wp_logout_url( home_url() ) inside the wp_logout_url($redirect) function. In that way it always redirect to homepage whenever logout is triggered.
Hi. It’s not normally recommended to edit the wordpress include files directly because they can cause problems but more importantly because any time that you choose to update your installation there is a chance that your modification will be rewritten by any new code changes in the wordpress update. It’s better to use the functions.php file of your theme or create a custom plugin.
Hi, your piece of code was working good.
HOW ABOUT WRONG LOGIN CREDENTIALS?
Do you also have a code that redirect to a page and give a message?
Hope to be in Mexico next month. To cold here in Europe!
Hi Martin. I know this is a bit late but I published a post regarding redirection after invalid login. Check it out http://projectivemotion.com/2011/12/16/redirect-failed-login-attempt-wordpress/
Hope you’re enjoying the weather wherever you are ! lol