Archived topic
Disable generatepress Schema only on Homepage
15 replies · Started by Sars on March 5, 2022
Dear Team how to disable default generatepress schema on homepage.
Thank you
Hi there,
try this PHP snippet:
add_filter( 'generate_schema_type', function($schema){
if ( is_home() ) {
$schema = '__return_false';
}
return $schema;
} );
You may need to change the conditional tag depending on what home page stating you have:
https://docs.generatepress.com/article/using-hooks-conditional-tags/
<?php if ( is_front_page() ) : ?>
add_filter( 'generate_schema_type', function($schema){
if ( is_home() ) {
$schema = '__return_false';
}
return $schema;
} );
<?php endif; ?>
Thanks a lot. Is this the correct Code @david
This:
add_filter( 'generate_schema_type', function($schema){
if ( is_front_page() ) {
$schema = '__return_false';
}
return $schema;
} );
Thanks David,
But I am unable to get this sentence:
You may need to change the conditional tag depending on what home page stating you have:
I am using a Masonry theme i think - https://nationalroofingsupply.ca
Hi Sars,
The conditional tag is_front_page() is the right one as your front page is a static page.
For your reference: https://codex.wordpress.org/Conditional_Tags
Can you make sure cache is cleared?
Thanks Ying for your help!
Glad to hear that :)
You are welcome!
I added the Code
But and did "Execute PHP" , but still I am seeing the Default Schema Ying
I used this code:
<?php if ( is_front_page() ) : ?>
add_filter( 'generate_schema_type', function($schema){
if ( is_home() ) {
$schema = '__return_false';
}
return $schema;
} );
<?php endif; ?>
Did you add this code to a hook?
If so, please remove it. This code should be added using one of the methods introduced here:
https://docs.generatepress.com/article/adding-php/
yes, I removed and added, saved and activated via the php snippet plugin, But still seeing schema on front page
https://pasteboard.co/a7rc1cVYCt3D.png
Thank you
Can you try David's code here?
https://generatepress.com/forums/topic/disable-generatepress-schema-only-on-homepage/#post-2143637
I tried that too leo,
But it is still not working.,
https://pasteboard.co/FtRBA4FPwrSM.png
Thank You
The code in your screenshot is not exactly the same as David's code here:
https://generatepress.com/forums/topic/disable-generatepress-schema-only-on-homepage/#post-2143637
Can you copy and paste David's code?
Extremely sorry for consuming your time.
Thanks a lot. My mistake. It is working well now.