How to get wordpress site title name from url ?

get wordpress site title name from url 

<?php

// Exit if accessed directly
if ( !defined( ‘ABSPATH’ ) ) exit;

function oops_script(){

wp_enqueue_style(“oops-style”, plugin_dir_url(__FILE__).”style.css”);

}
add_action(“wp_enqueue_scripts”,”oops_script”);

/*+++++++ Declaring Global Variables +++++++++*/
$domain = site_url(); //or home
$domain = str_replace(‘http://’, ”, $domain);
$domain = str_replace(‘www’, ”, $domain);
$domain = str_replace(‘.com’, ”, $domain);
$domain = str_replace(‘/’, ”, $domain);
$domain = str_replace(‘localhost’, ”, $domain);

 $wpsite = $domain;

?>

use it in another page with global variable

<?php

global $wpsite;

echo $wpsite ;

?>

Leave a Reply

Your email address will not be published. Required fields are marked *