Displaying website title with a short code

By Webmaster

Posted: 14m & 16d ago
2 min read

👁 Views: 337

(0) Leave a Comment

Shortcode - WpScriptly

This guide provides a detailed explanation on how to use a short code to dynamically display the title of a website. It covers the steps required to create and implement a short code that retrieves and displays the site’s title. This functionality can be particularly useful for web developers and content managers who want to ensure consistent and automatic display of the website’s title across different sections of their site. The guide includes practical examples and best practices to help users seamlessly integrate this feature into their web pages, enhancing both the efficiency of content management and the user experience.

I use fluent snippet plugin for all my functions, JS and CSS needs

PHP Script

function website_name_shortcode($atts, $content = null) {
// Get the website name
$website_name = get_bloginfo('name');
// Return the website name within a CSS class
return '<span class="website-name">' . esc_html($website_name) . '</span>';
}
add_shortcode('website_name', 'website_name_shortcode');

CSS

.website-name  { 
 color: #000;
 font-weight: 600;
}

Shortcode to be used on the website

[website_name]

Example image:

Displaying website title with a short code
Displaying website title with a short code

Please customize the css any way that will match your website.

Author: Webmaster

Hey, I’m Scot, the guy behind WpScriptly. I create simple, no-fluff WordPress plugins and tools to make your site easier to manage and more powerful. Everything I build is tested on my own projects first — if it’s here, it’s because it works. Thanks for checking out the site. Hope you find something useful at Wp Scriptly.

Follow me at:

Add your first comment to this post