How To Restrict Your Site’s Header Content

Updated on March 1, 2024

What’s in This Guide

This guide shows how to use Content Control to display one header for logged-out visitors and another for logged-in visitors.

We’ll give you a step-by-step demo by editing the Twenty Twenty-Four theme header template part.

Let’s go 😉

What We’re Aiming For

The logged-out header will have:

  • The site logo.
  • A title that says “Logged-out Menu”.
  • One navigation item that links to the default Sample Page.

Logged-Out Header

Logged-Out Header

Logged-In Header

The logged-in header will have:

  • The site logo.
  • A title that says “Logged-In Menu”.
  • Three navigation links: Sample Page, Blog, and Help Docs.

Logged-In Header

Steps

Follow these steps to set up your header template part and create the Block Controls that decide who sees the logged-out/logged-in content.

Heads up!
You need only 1 header template part. You’ll use Block Controls inside the template part to display the different headers. That means you don’t need to create 2 separate headers (saves time).

1. Hover over Appearance in the WordPress admin side menu and click Editor

Appearnce ≫ Editor (Full Site Editing) Marked Up

2. Click Patterns

Cc V2 Restrict Header Patterns

3. Click Manage all template parts

Cc V2 Restrict Header Manage Template Parts

4. Click Header

Cc V2 Restrict Header Template Parts

In our example, we’re editing the site’s default header template part. If you don’t want to touch that default header, add a new header and edit that new one instead.

5. Create the header content

Create your logged-out and logged-in content. We suggest using a Row block for each.

In the example below, we have 2 rows. Each row has the site logo, a title, and navigation links. The first row is for logged-out visitors. The second row is for anyone who’s logged in.

Cc V2 Header Block List View 1024W

You can copy the HTML code for our example up on GitHub.

Let’s set up the logged-out header content first.

6. Click the logged-out content block

Logged-Out Row Block Selected

7. Click Enable Controls

Enable Controls Toggled Turned On

8. Expand User Rules and click Logged Out Users

User Rules ≫ Logged Out Users Selected

Now, let’s take care of the logged-in header content.

9. Click the logged-in content block

Logged-In Header Content Selected

10. Expand User Rules and click Logged In Users

Keep USER ROLE as Any.

User Rules ≫ Logged In Users Selected

11. Click Save

Header Save

12. Click Save to confirm

Header Save Template Part Confirm

13. Test your changes

Navigate to your homepage while still logged in. You should see the logged-in header.

Now, log out and return to your homepage while still logged out. You should see the logged-out header.

If all that works, congratulations! 🎉

If not, make sure to clear all your caches (site, hosting, CDN, database, and browser).

Still not working? Give us a shout via our support page.

What’s Next?

You can also restrict your site’s sidebar and footer content. Check out how to do that next.

Is this article helpful? What are your feelings