WordPress: Disable Comments on Old Posts Automatically
Stop spam on old WordPress posts by closing comments automatically after a set number of days.
Brand the WordPress login page with your own logo and link — a few lines of code, no plugin needed.
26 lines · Updated Nov 26, 2026
<?php
// Add to your theme's functions.php or a code-snippets plugin.
add_action('login_enqueue_scripts', 'my_custom_login_logo');
function my_custom_login_logo() {
$logo = get_stylesheet_directory_uri() . '/images/logo.png';
?>
<style>
#login h1 a {
background-image: url(<?php echo esc_url($logo); ?>);
background-size: contain;
width: 200px;
height: 80px;
}
</style>
<?php
}
add_filter('login_headerurl', function () {
return home_url();
});
add_filter('login_headertext', function () {
return get_bloginfo('name');
});
The default WordPress login screen shows the WordPress logo and links to wordpress.org — fine for your own blog, but unprofessional on a client's site. This snippet replaces the logo with your own, points the logo link to the site's homepage and changes the hover text to the site name, all without a plugin.
login_enqueue_scripts to print a little CSS on the login page only, replacing the background image of the logo.login_headerurl filter to change where the logo links to.login_headertext filter to change the logo's accessible text to your site name.background-size so the logo is not cropped.Branding the login page is cosmetic. To protect logins, also use strong passwords, two-factor authentication and login rate limiting.
Related: Disable comments on old posts · Log 404 errors
Add the code to your theme's functions.php or a code-snippets plugin. Upload your logo to your-theme/images/logo.png and adjust the width and height to match it.
Share this snippet
Stop spam on old WordPress posts by closing comments automatically after a set number of days.
Add your own widget to the WordPress dashboard — show today's orders, a checklist, or quick links for your team.
Log every 404 on your WordPress site so you can see which broken links visitors actually hit — and fix them.