- This topic has 8 replies, 1 voice, and was last updated 4 years, 8 months ago by
robchanoi.
-
AuthorPosts
-
January 16, 2018 at 11:37 pm #472956
Roman
Hi!
Is it posible to delete or change schema, for example “itemtype=’http://schema.org/CreativeWork'”?
I have installed Code Snippet plugin and added snippet with code from another topic:
add_filter( ‘generate_article_schema’, ‘example_function_name’ );
function example_function_name()
{
return ”;
}But it’s didn’t work. Did I do something wrong?
January 17, 2018 at 9:59 am #473419Tom
Lead DeveloperLead DeveloperHi Roman,
Currently it’s not possible to remove the markup completely.
We do have plans on changing how attributes are added to elements, which will allow you to remove everything from microdata to classes and IDs.
January 17, 2018 at 10:51 am #473462Roman
Can I replace or remove only values of itemtype?
I found your code in another topic, which is looks like what i’ve been searching for:add_filter( 'generate_body_itemtype', 'tu_custom_body_itemtype' ); function tu_custom_body_itemtype( $type ) { if ( is_page( array( 'about', 'about-us' ) ) ) { return 'AboutPage'; } elseif ( is_page( array( 'contact', 'contact-us' ) ) ) { return 'ContactPage'; } elseif ( is_search() ) { return 'SearchResultsPage'; } elseif ( is_front_page() ) { return 'WebPage'; } elseif (is_single() ) { return 'Article'; } else { return 'WebPage'; } }I’ve tried to add this (with ‘generate_article_schema’ instead ‘generate_body_itemtype’) and previous code in Code Snippet plugin and directly to new plugin file. It still doesn’t work. Do I need to add only this code or somthing else? Or these filters not working now?
January 17, 2018 at 11:33 pm #473818Tom
Lead DeveloperLead DeveloperAbsolutely, that should work.
You can see the filter here: https://github.com/tomusborne/generatepress/blob/2.0.2/inc/markup.php#L47
So if you switch out the filter name and change
CreativeWorkto another valid itemtype, it should update.January 19, 2018 at 2:01 am #474710Roman
Can you check this code on your site?
I simplified the code as much as possible, to prevent any errors:add_filter( 'generate_article_schema', 'tu_custom_body_itemtype' ); function tu_custom_body_itemtype( $type ) { return 'WebPage'; }Still have “CreativeWork” on all pages. 🙁
January 19, 2018 at 10:32 pm #475382Tom
Lead DeveloperLead DeveloperInstead of
generate_article_schema, trygenerate_article_itemtype.January 26, 2018 at 6:53 pm #480876Roman
It works with
generate_article_itemtype. Thanks!January 26, 2018 at 11:35 pm #480922Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
June 7, 2021 at 2:48 am #1813090robchanoi
Edit – wrong thread.
-
AuthorPosts
- You must be logged in to reply to this topic.