Displaying website title with a short code

By Webmaster

Posted: 13m & 4d ago
🕑 2 min read

👁 Views: 302

(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 '' . esc_html($website_name) . '';
}
add_shortcode('website_name', 'website_name_shortcode');

CSS

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

Shortcode to be used on the website

Wp Scriptly

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, Admin at WpScriptly

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.

*These scripts and plugins are provided as is with no guarantees or warranties. If you need assistance or run into issues, feel free to reach out via the contact page.

Comments: