简体   繁体   中英

Dynamic Wordpress Blog Name and Blog Description

I am trying to define my Wordpress website title(Blog Name) and tagline(Blog Description). I am new here and also don't know coding of Wordpress.

if ($country_code=="UK") {
    define('WP_BLOGNAME', 'FOR UK');
    define('WP_BLOGDESCRIPTION', 'UK');
}
else if ($country_code=="AU") {
    define('WP_BLOGNAME', 'FOR Australia');
    define('WP_BLOGDESCRIPTION', 'Australia');
}

I want define this in wp_config.php If possible kindly help or give me other solution.

I don't think you can specify title and tagline in wp-config.php. You should be able to use filters to change the tagline and blog name though. In a plugin or your theme functions.php you can add this:

add_filter( 'bloginfo', 'mytheme_bloginfo', 10, 2 );
function mytheme_bloginfo( $text, $show )
{
    $country_code = ...   
    if ($show == 'description') {
        if ($country_code=="UK") {
            $text = "UK Description";
        } else {
            $text = "AU Description";
        } 
    }
    else {
        if ($country_code=="UK") {
            $text = "UK Title";
        } else {
            $text = "AU Title";
        }                
    }
    return $text;
}

I have added below code in function.php file of my theme and I have changed Blog name and blog description.

add_filter( 'option_blogdescription', 'mytheme_bloginfo', 10, 1 );
function mytheme_bloginfo( $text )
{

$country_code =  ...;   
        if ($country_code=="UK") {
            $text = "UK Description";
        } else if ($country_code=="AU") {
            $text = "AU Description";
        }                 

    return $text;
}

add_filter( 'option_blogname', 'mytheme_bloginfo_name', 10, 2);
function mytheme_bloginfo_name( $text )
{
$country_code =  ...;   
        if ($country_code=="UK") {
            $text = "United Kingdom";
        } else if ($country_code=="AU") {
            $text = "Australia";
        }                 

    return $text;
}

It is working code. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM