Customize the <title> tag for all pages and

2019-08-27 04:27发布

I have been researching a problem that I have and came across this discussion:

https://gtranslate.io/forum/how-not-translate-the-title-meta-tag-t4852.html

In there the answer provided is to use this html syntax:

<title class="notranslate">Example</title>

The issue at hand is to prevent Google Translate from translating the <title> tag. What I have is a WordPress website:

www.publictalksoftware.co.uk

I don't know how to go about changing the site to apply this syntax for all the <title> tags on my posts and pages. I read up about wp_head() but am getting lost.

Any advice appreciated.

Update

The header.php for the theme I am using has this code:

<?php wp_head(); ?>

    <?php if ( get_option('google_analitic_code') ) : ?>
        <?php echo get_option('google_analitic_code'); ?>    

    <?php endif; ?>
</head>

标签: wordpress
1条回答
Melony?
2楼-- · 2019-08-27 04:52

Add Below function in function.php

remove_action( 'wp_head', '_wp_render_title_tag', 1 );

Add Below code in header.php befode wp_head();

<title class="notranslate"><?php bloginfo('name');?> | <?php wp_title();?></title>

Hope this works for you.

查看更多
登录 后发表回答