• Resolved Richard D'Angelo

    (@craftpronj)


    Firstly, thank you for an outstanding plugin. I’ve been using Schema microdata for a long time and am a huge fan of AMT’s auto-implementation.

    A QUESTION
    I’ve looked and looked, but I can’t seem to find a good resource for PHP filter snippets that may help me achieve the schema markup via AMT that I’m looking for (see “SUGGESTION” below). Is there a collection of copy-and-paste filter-snippets out there? I’m only a novice at PHP but I still have a long functions.php in my child theme, and I’m pretty good at Schema – if given the framework for making the changes to the Schema markup that I’m looking for I’m sure I can solve all this myself.

    A SUGGESTION
    The only issue I have with the way AMT implements schema.org markup is that it makes Pages and Posts both Article itemtypes. It may very well be the case that this works fine for the majority of users. My website, CraftPro Contracting, is for my home improvement business. My pages are for my services and my posts are for my blog. Perhaps in a future release you can make it so that Posts are Articles and Pages are marked up as simply WebPage, or some type of option for choosing an itemtype that goes beyond the post format. Just a thought – I see how much you support this plugin and how often you help out its users, so if this is a low priority thing then no worries. I’m still keeping the plugin.

    Thanks to anyone who can help!

    – Richard D’Angelo, owner
    CraftPro Contracting of Morris County NJ

    https://wordpress.org/plugins/add-meta-tags/

Viewing 15 replies - 1 through 15 (of 26 total)
  • Plugin Author George Notaras

    (@gnotaras)

    Hello Richard,

    Glad you like the plugin!

    It is in my plans to create a webpage/wiki that contains a collection of snippets that customize the plugin’s functionality in various ways. Users will be able to use them as is or as a starting point for their own customization. I had started such an effort in the description page of the plugin, but unfortunately this facility provided by wordpress.org is not flexible enough for this kind of work. Time permitting, I’ll soon have a solution for this.

    About your suggestion, you are absolutely right. The main object type should be customizable and also automatically setting posts to Article and pages to WebPage makes a lot of sense.

    However, this modification would possibly require the replacement of the ‘articleBody’ attribute with the ‘text’ attribute which is common to all CreativeWork derivatives. Currently, because of the way it is implemented, ‘articleBody’ cannot be modified even with a filter. This will be greatly improved and in the next release all of the above will be customizable and possibly your suggestion will be implemented and become the default behavior. Please note that it might take a while until I study the specification more thoroughly.

    Thank you for your feedback and ideas!

    Kind Regards,
    George

    Thread Starter Richard D'Angelo

    (@craftpronj)

    EXAMPLE #2 on the plugin description page is an example of what I’m looking for. Currently am using that filter to apply the metadata to an array ‘post’ and ‘jetpack-portfolio’:

    function limit_metadata_to_post_types( $post_types ) {
        return array( 'post', 'jetpack-portfolio');
    }
    add_filter( 'amt_supported_post_types', 'limit_metadata_to_post_types');

    Still I’d like to have more control of the Schema and any help in the form of filters would be appreciated. If I were more fluent in PHP I could write them myself but, alas, I’m only a home improvement contractor who dabbles in web design.

    Thread Starter Richard D'Angelo

    (@craftpronj)

    It is in my plans to create a webpage/wiki that contains a collection of snippets that customize the plugin’s functionality in various ways. Users will be able to use them as is or as a starting point for their own customization.

    That would be incredibly useful! Looking forward to seeing something like that. I’m surprised no one has published any such snippets already, because there is a lot of customization possible if one has the PHP coding ability.

    About your suggestion, you are absolutely right. The main object type should be customizable and also automatically setting posts to Article and pages to WebPage makes a lot of sense.

    However, this modification would possibly require the replacement of the ‘articleBody’ attribute with the ‘text’ attribute which is common to all CreativeWork derivatives.

    Ahh ok. I didn’t know itemprop=”articleBody” was hard-coded (for lack of a better word) and yeah that isn’t an attribute of WebPage. The “text” itemprop would work just fine. Sounds like you’re really on top of it. Thank you for taking the time to respond!

    If you have any resources/links for me re: customizing the Schema placement I’m all ears. If not, feel free to mark as resolved and thanks again for your speedy reply.

    Plugin Author George Notaras

    (@gnotaras)

    Hi Richard, thanks for your reply.

    Currently I’m not maintaining a list of snippets. Time permitting this will happen soon.

    The Schema.org generator will be improved and it will be customizable.

    Thank you for your feedback.

    George

    Plugin Author George Notaras

    (@gnotaras)

    Hello Richard,

    In the upcoming v2.7.5 it will be very easy to customize the main Schema.org object. For instance, if you want pages to be of type ‘WebPage’, it can be done with a piece of code like the following:

    function amt_schemaorg_custom_main_object( $default ) {
        if ( is_page() ) {
            return 'WebPage';
        }
        return $default;    // Article
    }
    add_filter( 'amt_schemaorg_object_main', 'amt_schemaorg_custom_main_object' );

    For various reasons this won’t happen automatically for pages, at least for now. I’ll have to to do some more research about it.

    I hope this is OK.

    Thanks for your feedback!

    George

    Plugin Author George Notaras

    (@gnotaras)

    Richard, I’m marking this topic as resolved. Please feel free to reopen if necessary.

    George

    Thread Starter Richard D'Angelo

    (@craftpronj)

    Sounds great George thank you! Quick question: I use the Customizr theme (www.presscustomizr.com) and it already marks up every post and page with the WebPage itemtype in the body tag (in order to markup breadcrumbs – as far as I can see that’s the only reason). I wonder if 2 instances of WebPage would be a problem? I don’t think it would be. Thoughts?

    Plugin Author George Notaras

    (@gnotaras)

    Exactly, one of the main reasons I didn’t implement it to automatically set the main metadata object to ‘WebPage’ on pages is the fact that in 99% of the cases the breadcrumbs would be left outside of the WebPage itemscope. The other reason is also what you mentioned about the ‘WebPage’ object being set in the body element of the page in many themes or by other plugins.

    I wonder if 2 instances of WebPage would be a problem? I don’t think it would be. Thoughts?

    This is one of my questions as well. My guess is that 2 WebPage objects in the same web page could confuse the validator/parser. Even if it passes the validation, I still cannot think of a valid reason why two WebPage objects would exist in the same web page… IMHO, it should be avoided. (Update: I haven’t tested it in a validator)

    Thread Starter Richard D'Angelo

    (@craftpronj)

    I’ve tested two instances of the same itemtype in a validator and it “passes” but I still highly doubt it’s a best practice. I’ve been able to accomplish what I need with the code I pasted in my 2nd post in this thread: it eliminates the Article itemtype on pages, which is what I was looking for. And my pages are already marked up with the WebPage itemtype via my theme, which I suspect is the case for most themes (either WebPage or BlogPost, from my experience).

    If you can figure out a lightweight solution to make the itemtype customizable (for example, I use ContactPage for my business’ “Contact Us” page) and to make the Schema itemprops customizable that would sure be cool.

    But really I think as it stands right now with a few PHP hacks (maybe you could start a collection/wiki like you suggested? Many people would contribute I’m sure) it works well. I mean even Porch.com uses your plugin and they were started by two former Google guys so AMT does what it needs to do. The ability to customize would be nice but I understand you want to keep it simple and lightweight so, of course, it’s your call.

    Plugin Author George Notaras

    (@gnotaras)

    Unfortunately there are no plans to implement any customization of OpenGraph, Schema.org or Twitter Cards through a form in the post editing screen as it would open the path for more similar requests and that would be difficult to manage.

    I’m glad filters work fine for you.

    A v2.7.5 compatible customization example would be:

    function amt_schemaorg_custom_main_object( $default ) {
        if ( is_page('my-contact-page-slug') ) {
            return 'ContactPage';
        } elseif ( is_page('how-to-find-us') ) {
            return 'Map';
        } elseif ( is_page() ) {
            return 'WebPage';
        }
        return $default;    // Article
    }
    add_filter( 'amt_schemaorg_object_main', 'amt_schemaorg_custom_main_object' );

    I’ll try to make a collection of snippets in a wiki soon.

    Thanks for your feedback about these changes. It really helped to make the plugin more flexible and customizable.

    Best Regards,
    George

    Plugin Author George Notaras

    (@gnotaras)

    FYI, 2.7.5 will be skipped due to the many improvements and features. 2.8.0 will be released soon.

    George

    Thread Starter Richard D'Angelo

    (@craftpronj)

    The new update is excellent George. Your support of this plugin is fantastic. Congrats – it’s an excellent plugin and I couldn’t be happier.

    Plugin Author George Notaras

    (@gnotaras)

    Richard, thank you for your review and also for your useful feedback and ideas.

    Kind Regards,
    George

    PS: I’ll soon set up a wiki page with customization code snippets. There is still one task to complete before this happens: I’ll have to improve the metadata array by adding a proper key for each meta tag item and add some documentation about it. This will greatly simplify meta tag selection when customizing and also simplify code snippets.

    Thread Starter Richard D'Angelo

    (@craftpronj)

    No problem, George – this is definitely a 5-star plugin. Thanks for being so proactive about the support. I’m very, very much looking forward to the customization code snippets wiki! Keep us posted. That would be phenomenal.

    Hi George,

    I used the code above :
    function amt_schemaorg_custom_main_object( $default ) {
    if ( is_page() ) {
    return ‘WebPage’;
    }
    return $default; // Article
    }
    add_filter( ‘amt_schemaorg_object_main’, ‘amt_schemaorg_custom_main_object’ );

    to change the page from article to webpage but the rich snippets test tools dive me this error : articleSection: Realizzazione siti web internet. Google can not recognize the articleSection property of an object of WebPage kind

    Please help me
    Bye

Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘AMT's Schema: is there a Collection of PHP Filter Snippets for Customizing?’ is closed to new replies.