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

Adding a sidebar to wp-login.php

Here is my hack to add content above the login form using the login_body_class filter…

add_filter('login_body_class','login_body_hack',999);
function login_body_hack($classes) {
    $classes[] = 'PLACEHOLDER';
    add_filter('attribute_escape', 'login_body_filter_hack',999,2);
    return $classes;
}

function login_body_filter_hack($safe_text, $text) {

    // add whatever you like content here
    $newcontent="<div id="contentwrapper">CONTENT</div>';

    $replace="">"; // closes the body tag early
    $replace .= $newcontent;
    // some tag to be closed, as suffixed with the original ">
    $replace .= '<img src="https://wordpress.stackexchange.com/questions/233457/javascript:void(0);" style="display:none;'; 
    $safe_text = str_replace('PLACEHOLDER',$replace,$safe_text);
    remove_filter('attribute_escape', 'login_body_filter_hack',999,2);
    return $safe_text;
}

Note however that “as is” this will the content to all “login” pages (register, reset, lost password etc.) not just the login form one, so further checks would be needed to handle those cases.

Related Posts:

  1. User registration followed by automatic login
  2. Adding “Remember Me” in custom login
  3. How to change the wp-login.php page title?
  4. How build a custom login/register form with error handling?
  5. Change the footer text on the login page
  6. Changing user_nicename
  7. WordPress 4 invalid username special charachters issue
  8. How to place login logout link on menu that redirects users back to current page?
  9. display most popular tags in two columns
  10. Using a nonce in a Custom Login Form
  11. Constructing a custom login form using ajax
  12. automated tests as a user?
  13. dynamic sidebar not showing anything
  14. Remove username in emails or swap username for email
  15. Styling images coming from another blog
  16. PHP If user is logged in & on home page redirect
  17. WordPress shows registration link for non logged users
  18. Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
  19. Admin username and password
  20. How to show a dynamic_sidebar if main content content’s height is > a set amount?
  21. How to create a linked tag list in my sidebar
  22. Recovering WP Login Credintials in Code?
  23. Missing sidebar parameter “fix” – before_content
  24. Is it necessary to sanitize wp_set_password user input?
  25. WordPress custom login form using Ajax
  26. How to give new users two specific user role options upon WordPress user registration
  27. Wp-login appears White Screen, Error: Cannot modify header information
  28. How to: PHP Log Out Link?
  29. Login/logout in header
  30. Dynamic Sidebars & Echo
  31. Why is my cookie not unsetting upon logout? [closed]
  32. User management system similar to wordpress one?
  33. Programmatic Login from 3rd Party site
  34. Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
  35. getting logged in user info (wp-load.php) from parent directory
  36. Child page menu in sidebar
  37. Theme developement – incative sidebars
  38. Problem with login form
  39. Login to wordpress by clicking a link and specifying usernaname and password in url
  40. Generate sidebar depending on height of post
  41. Log in / Log Out Custom Button
  42. Should `wp_login` be used since it’s deprecated?
  43. How to redirect users based on role and content of redirect_to?
  44. Change CSS based on is_user_logged_in
  45. How to determine if the sidebar is empty? Or not active?
  46. How to display login form anywhere, when user isn’t logged in, without redirecting?
  47. How can I open up my administrative panel to everyone?
  48. Styling the second sidebar
  49. How can I add a new row in a separate database when someone registers via WordPress?
  50. One account with multiple logins
  51. Lost in trying to create user database system
  52. Shortcode to log user into current URL
  53. Removing sidebar on category pages
  54. I installed WordPress locally now how do I login?
  55. Change homepage content if user is logged in – BuddyPress
  56. Show login greeting above sub-menu links?
  57. Display Custom Field in Sidebar if Value is Present
  58. Stuck with sidebar registering
  59. is_user_logged_in returning nothing on custom page
  60. Don’t display a sidebar widget when on a specific page
  61. Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
  62. Can’t log in to WordPress wp-admin after adding code to functions.php
  63. Retrieve the whole widget sidebar and pass it inside an html
  64. Check if user had autologin & if so, logout
  65. Admin Panel 404 Error after login
  66. How to block specific user id in custom login form?
  67. Loading Widgets Via Child Theme
  68. Call WP Rest-Api to GET /users/me returned NOTHING in console
  69. Restrict wordpress access to logged users only
  70. Menu not updating for logged in users after redirect
  71. how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
  72. Change Login or Logout text based on status
  73. Display child-page links in sidebar on both Parent Pages AND Child Pages
  74. Redirect after login depending on the URL
  75. Redirecting the lost password page request when using a custon login page
  76. How do I send a POST request with params with WordPress REST API
  77. wp-login.php?redirect_to=https problem
  78. What image is this pulling?
  79. How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
  80. List users in a dropdown for login
  81. how to run a php code in widget?
  82. Not logged in when using http
  83. add bootstrap modal after login in wordpress
  84. if conditional in sidebar plugin Password content shortcode
  85. White screen after login attempt
  86. My custom widget won’t stay in the widget area after I refresh the widget page
  87. how to remove sidebar from particular one page
  88. Listing current pages subp page in list items in the sidebar
  89. Sidebar doesnt get updated?
  90. Redirect users not logged in to the standard login page (and back) from some posts and pages
  91. login redirect based on user role not work as expected
  92. How do I do so that people can register on my wordpress site?
  93. wp_login_url always redirects me to wp-admin
  94. I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
  95. Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)
  96. change div text and link for logged in users
  97. Sidebars panel in customizer
  98. wp-login – unable to redirect user to a custom login url
  99. Redirect to current URL and append specified URL parameter on unsuccessful login through Elementor login form widget
  100. Side bar only if it’s not a single post or a specific page
Categories PHP Tags login, php, sidebar
AJAX call in backend results in empty update_option
How can I add an “Attach image to this post/page” link on the Add Media lightbox?

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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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