If I have understood correctly the work around could be to put back the <h1></h1> tag and make it hidden on page load using JavaScript.
Do not hide using display:none or same background color to make it invisible to human eye. Google ignores both.
But if you use the JavaScript way Google will still read it.
Hope this helps.
How can I do with js? I have to make h1 invisible to human eye but not to google. Please help me
First give some ID to the <h1> tag you want to hide, for example <h1 id="hide_it">Your content here...</h1>.
Now open your footer.php file add this before ending </body> tag.
<script type="text/javascript">
$(document).ready(function(){
$("#hide_it").hide();
});
</script>
I am not sure about how the layout is structured for this particular theme. But the above should work.
Let me know how this goes.
PS: The reason why hiding with JavaScript still leaves it visible to SEO is the element would get hidden in generated output. If you simply use View Source of your page you will still be able to see the element present there. But if you see Generated Source of the same page then the markup of the same h1 will look like this:
<h1 id=”hide_this” style=”display:none;”>Your content</h1>. Good thing with Google is it only deals with normal Source , not generated source.
Where I have to paste this? <h1 id="hide_it">Your content here...</h1>
You said you removed the h1. So just put it back where it was with the site title. Only thing is add the id "hide_it" to this h1 for referencing in the JavaScript.
Ok, but I added h1 by WordPress consolle “site title”. I’m not an expert. In what file can I find h1 to add ID?
That h1 should ideally be residing inside your theme’s header.php file.
This inìs my header.php:
<?php
/**
* The header for the OnePress theme.
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.ww.wp.xz.cn/themes/basics/template-files/#template-partials
*
* @package OnePress
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php do_action( 'onepress_before_site_start' ); ?>
<div id="page" class="hfeed site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'onepress' ); ?></a>
<?php
/**
* Hooked: onepress_site_header
*
* @see onepress_site_header
*/
do_action( 'onepress_site_start' );
?>
π
I don’t know how can I do. π
-
This reply was modified 9 years, 1 month ago by
ciccione82.
hey @ciccione82
I recommend you install this plugin to add custom js/css :
https://ww.wp.xz.cn/plugins/custom-css-js/
then add in custom js :
jQuery( function($) {
$('.site-title').hide();
});
Let me know how it goes!