WordPress wp_register() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

Definition

In WordPress, wp_register() prints a link that depends on the visitor. If the visitor is not logged in and registration is open, it prints a "Register" link. If the visitor is logged in, it prints a "Site Admin" link to the dashboard.

If the visitor is not logged in and registration is closed, nothing is printed.

Syntax

It is often used inside a list, with the default list item wrapper.

WordPress
<ul>
  <?php wp_register(); ?>
</ul>
CallWhat it does
wp_register()Prints the link inside a list item.
wp_register( '<p>', '</p>' )Wraps the link in a paragraph.
wp_register( '', '', false )Returns the bare link.

Allow sign-ups in Settings > General > Anyone can register.

Full declaration
WordPress
wp_register( string $before = '<li>', string $after = '</li>', bool $display = true ): void|string

Parameters

ParameterDescription
$beforestring. HTML placed before the link. Default is <li>.
$afterstring. HTML placed after the link. Default is </li>.
$displaybool. true (default) prints the link. false returns it.

Return Value

Return ValueDescription
voidWhen $display is true, the link is printed.
stringWhen $display is false, the link HTML is returned (or an empty string).

WordPress Examples

Three short theme examples. Each one shows the code and what it prints.

Example 1 — Default link

Use it inside a list.

WordPress
<ul>
  <?php wp_register(); ?>
</ul>

How It Works

  1. The function checks the login state.
  2. Guests see Register, members see Site Admin.
  3. The default wrapper is a list item.

Example 2 — Change the wrapper

Use a paragraph instead of a list item.

WordPress
<?php wp_register( '<p class="reg">', '</p>' ); ?>

How It Works

  1. The first two arguments replace the default tags.
  2. Nothing else about the link changes.
  3. Use any HTML you like.

Example 3 — Return the link

Get the link and print it yourself.

WordPress
<?php
$link = wp_register( '', '', false );
if ( $link ) {
  echo '<span class="nav-reg">' . $link . '</span>';
}

How It Works

  1. $display is false, so the link is returned.
  2. An empty result means there is no link to show.
  3. We print the wrapper only when a link exists.

Frequently Asked Questions

It prints a Register link for guests when sign-ups are open, or a Site Admin link for logged-in users.
The visitor is a guest and registration is closed. Turn on Anyone can register in Settings > General.
Pass your own before and after values as the first two arguments.
Pass false as the third argument: wp_register( '', '', false ).

Next: wp_title()

Print or return the page title for the head of the page (older theme method).

wp_title() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful