• Resolved technabob

    (@technabob)


    Even though a page can belong to multiple WordPress categories, and therefore have multiple OG article:section tags from your plugin, Facebook doesn’t seem to care for this, and automatically just goes with the first one. That said, their debugger throws a warning because of this, and I’m not sure if it has any negative consequences as a result.

    “The parser’s result for this metadata did not match the input metadata. Likely, this was caused by the data being ordered in an unexpected way, multiple values being given for a property only expecting a single value, or property values for a given property being mismatched. Here are the input properties that were not seen in the parsed result: ‘article:section'”

    Here’s an example page that throws this message in the facebook debugger:
    http://technabob.com/blog/2015/05/27/chocolate-nike-air-max-90/

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

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

    (@gnotaras)

    Hi technabob,

    I’m sorry for my late reply.

    Initially, the default behavior was to generate only one ‘article:section’ meta tag using the *first* category as returned by the relevant WP API call. This way, if the post had multiple categories, only the one that was on the top of the alphabetically ordered list was used. I had received feedback to change this, so the default functionality changed.

    The current functionality leads to the problem you described, if multiple categories have been set.

    In this case there is no right or wrong. Facebook supports one ‘article:section’, while WordPress supports multiple.

    The only workaround that makes sense is to use only *one* category on your posts, if full compatibility with Facebook is the goal.

    I’m afraid this functionality won’t be changed. But I’ll see what can be done by providing a filter hook so as to be able to fix it with a custom filtering function.

    George

    Plugin Author George Notaras

    (@gnotaras)

    In the upcoming 2.8.4, if multiple categories are used per post, it will be possible to filter the list of categories by attaching a filtering function to the ‘amt_post_categories_for_opengraph’ and ‘amt_post_categories_for_schemaorg’ filter hooks.

    If you need sample code, please let me know.

    I’m marking this topic as resolved.

    George

    Thread Starter technabob

    (@technabob)

    Thanks, George. I’m definitely not going to be cutting back on the number of categories I use, but would love to be able to set just a single section in the og tags for Facebook, since they’re the number one consumer of that data for us.

    Plugin Author George Notaras

    (@gnotaras)

    Hi technabob.

    I see. Here is some sample code that returns only the first category for Opengraph generator:

    function amt_opengraph_force_one_section( $categories ) {
        if ( ! empty($categories) ) {
             return array_slice($categories, 0, 1);
        }
        return $categories;
    }
    add_filter( 'amt_post_categories_for_opengraph', 'amt_opengraph_force_one_section' );

    Hope this helps. (will be valid in 2.8.4)

    George

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multiple OG article:section tags not supported by Facebook’ is closed to new replies.