- This topic has 17 replies, 3 voices, and was last updated 3 years, 4 months ago by Tom.
-
AuthorPosts
-
November 20, 2020 at 5:30 am #1538782Dmitry
I have read all the posts about
generate_article_schema
………………………………………….
I don’t know how to change schema types to the <article> element.
https://github.com/tomusborne/generatepress/blob/2.0.2/inc/markup.php#L47
I don’t want to useCreativeWork
I do not need<"json-ld">
All the examples given before do not work!
Explain, please, what was your idea? When you created this filter.
Why did you create this filter if you propose to disable it everywhere on the forum?
https://docs.generatepress.com/article/generate_article_schema/
………………………………………….
I think that on the “contact” page shouldn’t beCreativeWork
scheme.
https://generatepress.com/contact/
………………………………………….
How to manage types of schema without SEO plugins?
How to manage types of schema without a child theme?
I use GP Premium: 1.12.2.November 20, 2020 at 5:55 am #1538803DavidStaffCustomer SupportHi there,
you can use
generate_article_itemtype
filter.
Heres an example to change the schema itemType toContactPage
on a page with a slug ofcontact
add_filter( 'generate_article_itemtype', function( $type){ if ( is_page('contact') ) { $type = 'ContactPage'; } return $type; });
Adding PHP: https://docs.generatepress.com/article/adding-php/
November 20, 2020 at 6:56 am #1539065DmitryI didn’t ask about
generate_article_itemtype
which changes schema types to the<article>
element.
I am creating a page with Gutenberg using GENERATEBLOCKS.
And the<article>
section appears automatically for all pages.
And it has a default valueitemtype="https://schema.org/CreativeWork"
Take a look at the code on this page and you can see what I’m talking about!November 20, 2020 at 2:15 pm #1539471TomLead DeveloperLead DeveloperHi there,
generate_article_itemtype
applies to the<article>
element – not the<body>
.The link you provided links to our contact page.
Let us know 🙂
November 21, 2020 at 10:44 am #1540320DmitryYes, this is your site 🙂
I have already corrected the message, there was a mistake.
What is this filter for then?The generate_article_schema filter allows you to change the itemtype schema value for the article element.
How to remove a schema only from
<article>
Please tell me why you are using schema in<article>
?November 21, 2020 at 11:11 am #1540361TomLead DeveloperLead DeveloperTo remove it, you can try this:
add_filter( 'generate_article_microdata', '__return_empty_string' );
We add basic markup here as it’s the content container.
November 21, 2020 at 12:19 pm #1540411DmitryHow do you want to keep the hierarchy?
schema.org > Thing > CreativeWork
schema.org > Thing > Organization
As you can see CreativeWork and Organization the same parent type.
And if you want to create a contact page on the site (I think so)
You need to use a code like this:
itemtype="https://schema.org/ContactPage"
for the tag<body>
itemtype="https://schema.org/Organization"
for the tags<article>
or<div>
And the use of the<article>
tag on the contact page is generally questionable.
If you change the CreativeWork to Organization, the propertyitemprop="text"
will not be deleted!
So I’m asking you, please, tell us in more detail about how you conceived it?November 22, 2020 at 12:10 pm #1541432TomLead DeveloperLead DeveloperWe wanted to provide basic schema that would fit the majority of websites. When it comes to things like Contact pages, the theme doesn’t know which page you’re referring to, and it doesn’t have the necessary Organization data.
If we wanted to include more complex schema markup, we would need to add more options when it comes to organization details – name, logo etc..
This is something we considered, but things are moving away from microdata towards JSON-LD, so it wouldn’t make much sense to add weight to the theme for something that may be obsolete very soon.
If you need complex schema, you’re much better off using a schema plugin that has a lot of configuration, otherwise, you’re going to be messing with PHP filters/conditions etc..
Basically, the included schema is meant to be very simple so it suits the most people. For users who need more out of it, a schema plugin is the way to go – it’s the same when it comes to SEO options – that’s not something you want in the theme.
November 22, 2020 at 7:56 pm #1541706DmitryWell, now it’s clear, but how to set the value of the main tag for Pages and Posts?
How to remove<article>
tag from Pages eg.November 23, 2020 at 9:25 am #1542709TomLead DeveloperLead DeveloperYou want to remove the entire
<article>
element, or just the schema?November 23, 2020 at 9:41 pm #1543473DmitryIf you can’t manage schema types on site pages.
The question is how to set the value of the main tag for Pages and Posts
If this is not possible using filters, then I would like to remove it from Pages, but not from Posts.November 24, 2020 at 11:17 am #1544941TomLead DeveloperLead DeveloperThis is how you change the main article schema for specific pages: https://generatepress.com/forums/topic/creativework/#post-1538803
Is that what you mean by “main” tag? Or do you mean the
<body>
element?You can remove it from all pages like this:
add_filter( 'generate_article_microdata', function( $data ) { if ( is_page() ) { return ''; } return $data; } );
November 24, 2020 at 10:14 pm #1545476DmitryNo, I’m talking about
<article>
.
Let’s answer the following points:
1. Since you cannot flexibly edit its schema, then how to delete<article>
2. If you use thegenerate_article_itemtype
filter, then the following tag<div>
with the valueitemprop="text"
does not change! What to do about it?
3. Why is there no tool for choosing a page template in the Page Attributes. Do you think all pages should have a template with the<article>
tag? This feature was introduced in WordPress 4.7. Page Templates for Custom Post TypesNovember 25, 2020 at 10:10 am #1546835TomLead DeveloperLead Developer1. If you need to change the actual
article
tagname, you would need a custom template: https://github.com/tomusborne/generatepress/blob/3.0.2/content.php2. These itemprops are only removed if the site-wide schema is turned off, unfortunately. If you do add a custom template file, you can manually remove them.
3. In the majority of cases, the
article
tagname is fine – I don’t believe we’ve ever had another request to change it. Adding a filter to be able to change it may be the best solution here.The functionality of our schema system isn’t very robust, as microdata is being used less and less these days with major SEO plugins taking care of JSON-LD.
November 27, 2020 at 4:30 am #1551767DmitryI understand that we are returning to the option using a child theme?
-
AuthorPosts
- You must be logged in to reply to this topic.