Site logo

Archived topic

CreativeWork

17 replies · Started by Dmitry on November 20, 2020

Viewing posts 1–15 of 18

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 use CreativeWork
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 be CreativeWork 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.

Hi there,

you can use generate_article_itemtype filter.
Heres an example to change the schema itemType to ContactPage on a page with a slug of contact

add_filter( 'generate_article_itemtype', function( $type){
    if ( is_page('contact') ) {
        $type = 'ContactPage';
    }
    return $type;
});

Adding PHP: https://docs.generatepress.com/article/adding-php/

I didn't ask about generate_article_itemtypewhich 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 value itemtype="https://schema.org/CreativeWork"
Take a look at the code on this page and you can see what I'm talking about!

Hi there,

generate_article_itemtype applies to the <article> element - not the <body>.

The link you provided links to our contact page.

Let us know :)

Yes, 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>?

To 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.

How 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 property itemprop="text" will not be deleted!
So I'm asking you, please, tell us in more detail about how you conceived it?

We 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.

Well, 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.

You want to remove the entire <article> element, or just the schema?

If 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.

This 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;
} );

No, 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 the generate_article_itemtype filter, then the following tag <div> with the value itemprop="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 Types

1. 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.php

2. 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.

I understand that we are returning to the option using a child theme?

This archived topic is closed to new replies.