Hide admin bar with a simple GET parameter

WordPress gives your website by default an Admin bar when logged in. Sometimes you just want to see a page without the admin bar. You can open the page in a incognito tab, but you can also just add ‘?nobar‘ to your url.

To let this work, you need to add the following code to your functions.php

if (isset($_GET['nobar'])) {
    add_filter('show_admin_bar', '__return_false');

Example for the url would be: https://domain.tld/?nobar