I need to insert code like this:
<head>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"url": "http://www.example.com",
"logo": "http://www.example.com/images/logo.png"
}
</script>
</head>
only in the homepage. If I use the “Google Analytics” section in the theme panel, this code will spread to all pages.
How can I put this only into homepage?
Hello,
Please try in this way -> http://prntscr.com/pgambn -> http://prntscr.com/pgamr3
<script>
jQuery(document).ready(function($){
if ( $('body').hasClass('home')) {
{
"@context": "https://schema.org",
"@type": "Organization",
"url": "http://www.example.com",
"logo": "http://www.example.com/images/logo.png"
}
}
});
</script>
This should work!
Thank you!
doesnt work, because I need a “particular” script to insert like:
https://jsonld.com/organization/
so I need a script with a type, I tried something like
<script>
jQuery(document).ready(function($){
if ( $('body').hasClass('home')) {
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"url": "https://www.notizieoggi24.it",
"logo": "https://www.notizieoggi24.it/wp-content/uploads/2019/09/logo-notizie-oggi-24.png"
}
</script>
}
});
</script>
but didnt work. However I saw the jQuery code into head section from HTML source code
yes but I need the entire script with “type etc” inside the other script due the jquery function
Hi,
Try this :
<script>
jQuery(document).ready(function($){
if ( $('body').hasClass('home')) {
{
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"url": "http://www.example.com",
"logo": "http://www.example.com/images/logo.png"
}
</script>
<script>
}
}
});
</script>
or this :
<script type="application/ld+json">
jQuery(document).ready(function($){
if ( $('body').hasClass('home')) {
{
"@context": "https://schema.org",
"@type": "Organization",
"url": "http://www.example.com",
"logo": "http://www.example.com/images/logo.png"
}
}
});
</script>
works but appears on all pages and not only homepage.
is there some file .php wheither I can put the code?
maybe something like:
https://wordpress.stackexchange.com/questions/194516/google-analytics-tracking-code-on-just-one-page
is there some file .php to put this? (maybe with the id of page)
I have resolved with this: https://it.wordpress.org/plugins/header-footer/