Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

logout redirect only from admin page

For your if condition, use the is_admin function to determine if the user is currently viewing a backend administrative dashboard page or are on the frontend of the site.

So your code above would resemble:

add_action('wp_logout','redirect_after_logout');

function redirect_after_logout(){
  if( is_admin() ) {
    wp_redirect( home_url() );
    exit();
  }
}

For more information, see the codex documentation at https://codex.wordpress.org/Function_Reference/is_admin

Related Posts:

  1. How to change redirect after moving a page to trash?
  2. WordPress redirects to login page when I enter url.com/index.php
  3. Check if wp-login is current page
  4. Check IF is a “single product page” and Check the “role” for a Redirect
  5. How to redirect on particular page in wordpress? [closed]
  6. Can I display the widget admin in the page admin?
  7. Change admin startpage to Pages-page?
  8. Only allow new subpages to be created
  9. Is there a way to remove or hide individual pages on the Edit Pages screen?
  10. Where does the 404 redirection happen?
  11. Associate Page with User
  12. How to disable Page Attributes dropdown in wp-admin
  13. Dashboard–> All Pages “How to create folders?”
  14. How to make certain page templates visible to admin only
  15. Password Protected Page Not Displaying Content After Entering Password
  16. Change the Default Pages Menu View in wp-admin
  17. Redirect “Sorry, you are not allowed to access this page.” to Home
  18. Add a Menu Link (to a WordPress Page) in the Admin Menu/Sidebar
  19. How to redirect a page to subdomain?
  20. Remove pages from backend list *and* update counter accordingly
  21. Slug is redirecting to 404
  22. Edit page’s “Restore the backup” link does nothing
  23. How to redirect login and register pages
  24. If a page does not exist, include a different page?
  25. Missing ‘Page Attributes’ in page edit
  26. How to redirect a page to another?
  27. Admin pages, edit notes of the title of posts and pages
  28. Can’t locate a hidden private page
  29. WordPress Admin Login Redirect Problem
  30. Role – edit page but not publish
  31. Page redirects to archive
  32. Unique page URL redirect to file_get_contents() at domain
  33. Adding Page URL to the Pages Admin Table
  34. Could be a namespace conflict (?) with login form and register form on the same page
  35. Change base URL of pages created by certain users
  36. Redirect page to default subpage
  37. How to use is_admin in page content?
  38. Edit page shown after login in WordPress?
  39. Can’t login to my admin area
  40. Bad pages redirection
  41. Page access only from a specific page in wordpress website
  42. Change page name in admin list
  43. Logout Redirect and also WP-login.php Redirect
  44. WordPress page not taking precedence over server directory
  45. Is it possible to restrict access to specific pages in the admin area based on the page slug?
  46. get_permalink not fetching correct pages
  47. Folder wordpress page redirect
  48. How to rewrite a page url
  49. 404.php only works if I’m logged in. Everybody else redirects to wp-login.php – why?
  50. redirect index.html inside folder to wordpress page of same name
  51. Custom page only editable by one user
  52. Publish page by invoking submit via jQuery
  53. How should I set up a Tumblr blog at a WordPress Page?
  54. accessing the Admin page
  55. remove “Edit” from select pages
  56. URL redirect to home page issue in word press site
  57. Trying to login to my site redirects me to the first page
  58. Cannot use old slug – it just 301s to site home page
  59. Make wordpress pages accessible for Woocommerce logged in users only
  60. Post id(login page) not found
  61. Adding CSS styles to Admin Area PAGES only (not POSTS or CPT)
  62. Group Pages based on Parent in Admin Area
  63. disable trashability for certain pages
  64. Custom admin menu for a selection of pages
  65. Pages redirect me to the homepage
  66. How to access variables from one plugin in another
  67. How can a user login on a wordpress page?
  68. How to change the default location where new post gets stored?
  69. How to make a secondary Pages Screen
  70. Remove element from admin page editing part
  71. how to update page without reloading the page builder?
  72. Slug of a child page is accessible with and without the parent slug in the URL
  73. Loading ACF Field content on a 404.php page
  74. Why can’t pages be categorized / tagged?
  75. Set different heights per screen size with inline styles CSS into the ‘Text’ section of a Page
  76. Add custom action to the page listing screen
  77. Adding in additional pages into a custom theme
  78. Login to admin by frontend form?
  79. My edits are not saved
  80. How to list pages from an author?
  81. Editing Pages Icons Are Not Showing Up – Why is this happening?
  82. How to sorted Parent Page in WP-admin
  83. WordPress Admin login redirect to homepage
  84. Display meta data attribute in user profile
  85. Add the same content to multiple pages
  86. wp_list_pages get the hole hierarchy for current page
  87. Pages in wp-admin is not found 404
  88. Shortcode runs when editing page
  89. how can i display children of my parent page in one of the children page (wordpress)
  90. Cannot Create A Page or Post in WordPress 5.2.1
  91. My English homepage will not update
  92. How to redirect user to Referrer Page using wp_signon in Custom Login Page in WordPress
  93. How to select what posts goes into which custom page template?
  94. WordPress default theme cannot get full page on entry content div
  95. Displaying all pages which comes under a category id
  96. Some pages can’t be updated – post_content field not updating
  97. How to filter page title for certain page?
  98. Can I use the wordpress loop in pages?
  99. Add addtional page parameter before loading the page
Categories pages Tags admin, login, pages, redirect
Why can’t MX records point to an IP address?
Including CSS files in HEAD based on page content

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress