Skip to main content
Login Join
Snippet · PHP

Display Website Name

Shared by Utsav Tilava · August 22, 2026

5 views
1 upvote
Back to Snippets

This snippet displays the name of the current WordPress website using a simple shortcode. It is useful for reusable headers, footers, and custom content.

<?php
function display_website_name() {

    return '<span class="website-name">' .
        esc_html( get_bloginfo( 'name' ) ) .
        '</span>';
}

add_shortcode( 'website_name', 'display_website_name' );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments