Example 1 — Default link
Use it inside a list.
<ul>
<?php wp_register(); ?>
</ul> How It Works
- The function checks the login state.
- Guests see Register, members see Site Admin.
- The default wrapper is a list item.

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.
It is often used inside a list, with the default list item wrapper.
<ul>
<?php wp_register(); ?>
</ul> | Call | What 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.
wp_register( string $before = '<li>', string $after = '</li>', bool $display = true ): void|string | Parameter | Description |
|---|---|
$before | string. HTML placed before the link. Default is <li>. |
$after | string. HTML placed after the link. Default is </li>. |
$display | bool. true (default) prints the link. false returns it. |
| Return Value | Description |
|---|---|
| void | When $display is true, the link is printed. |
| string | When $display is false, the link HTML is returned (or an empty string). |
Three short theme examples. Each one shows the code and what it prints.
Use it inside a list.
<ul>
<?php wp_register(); ?>
</ul> Use a paragraph instead of a list item.
<?php wp_register( '<p class="reg">', '</p>' ); ?> Get the link and print it yourself.
<?php
$link = wp_register( '', '', false );
if ( $link ) {
echo '<span class="nav-reg">' . $link . '</span>';
} $display is false, so the link is returned.Print or return the page title for the head of the page (older theme method).
12 people found this page helpful