Home / Admin / Restrict WP Heartbeat
Duplicate Snippet

Embed Snippet on Your Site

Restrict WP Heartbeat

Disable Heartbeat on the frontend unless a user is editing a post and throttle at maximum allowed 60 seconds.

Code Preview
php
<?php
// Restrict WP Heartbeat / Kiri Vadivelu / 2026
add_action( 'init', function() {
    if ( ! is_admin() ) {
        wp_deregister_script( 'heartbeat' ); // Disable heartbeat in frontend
    }
});
add_filter( 'heartbeat_settings', function( $settings ) {
    $settings['interval'] = 60; // Set to the maximum allowed 60 seconds
    return $settings;
});

Comments

Add a Comment