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

    (@gnotaras)

    Hello pjv,

    I see. This is a limitation of the current implementation. Until I find a generic way to add support for the detection of these descriptions, I’ll post some code to use as a workaround. (I’ll post it at some later time.)

    Thanks for your feedback.

    George

    Plugin Author George Notaras

    (@gnotaras)

    Now that I am looking at it, the current implementation should work just fine, but it does not. I’ll need more time to investigate it.

    Plugin Author George Notaras

    (@gnotaras)

    I think I’ve found the cause of the problem. WooCommerce, for an unexplained reason returns the term description enclosed in <p> tags. As a result, any cleanup/sanitization algorithms strip the whole description, and thus the generic one is used instead.

    Is this WooCommerce behavior new?

    Thread Starter pjv

    (@pjv)

    I can’t say if it’s new or not – I just discovered the issue this morning and hadn’t been monitoring the meta descriptions on these product category pages before.

    Thread Starter pjv

    (@pjv)

    Is this something you can work around in AMT or does it require a patch to WooCommerce? (I have contributed WC patches in the past).

    Plugin Author George Notaras

    (@gnotaras)

    As I see it, enclosing the description in <p> tags makes little sense, but should be taken care by the theme/plugin. It looks more like a bug than a feature. Then again I might be wrong.

    Of course, I could add code to strip these tags, so that the description is picked up correctly, but I would greatly appreciate it if we made sure this is not a WooCommerce bug first.

    Thread Starter pjv

    (@pjv)

    Are you talking about the <p> tag where the description is displayed on the page that I linked to, or somewhere else?

    I’m trying to determine whether that tag is coming from WC or from the theme. In doing so, I took a look at a non-WC category archive page on the same site (https://breadtopia.com/category/recipes/) and noted that in the AMT generated meta tags, the meta description correctly uses the description that is entered for the category, but the og:description and the twitter:description display the generic description instead of the entered one.

    I also notice that the theme is not displaying the entered description on that archive page as on the WC product category archive page, so I am still not sure whether it is WC or the theme that is wrapping the description.

    Plugin Author George Notaras

    (@gnotaras)

    Setting the following code to be displayed in the WooCommerce Product Category archive, it returns the description enclosed in p tags.

    var_dump(term_description());

    But, it does not seem to be the real cause.

    The fix is the following.

    1. Edit metadata/amt_opengraph.php and replace line 284 with the following:

    $description_content = sanitize_text_field( amt_sanitize_description( term_description( $tax_term_object->term_id, $tax_term_object->taxonomy ) ) );

    It turns out term_description requires both the term ID and the taxonomy slug in order to return the term description.

    I cannot recall if this was needed in older versions of WP. Nevertheless, it is a bug of AMT and it will be fixed in the next release. The basic metadata, the opengraph and the twitter cards generators are affected.

    Thanks for your feedback.

    George

    Plugin Author George Notaras

    (@gnotaras)

    I’m trying to determine whether that tag is coming from WC or from the theme. In doing so, I took a look at a non-WC category archive page on the same site (https://breadtopia.com/category/recipes/) and noted that in the AMT generated meta tags, the meta description correctly uses the description that is entered for the category, but the og:description and the twitter:description display the generic description instead of the entered one.

    In case of category / tag archives, the respective description is retrieved using category_description() and tag_description(). For custom taxonomy terms, their description is retrieved using term_description().

    Thread Starter pjv

    (@pjv)

    The fix is the following.

    1. Edit metadata/amt_opengraph.php and replace line 284 with the following:

    $description_content = sanitize_text_field( amt_sanitize_description( term_description( $tax_term_object->term_id, $tax_term_object->taxonomy ) ) );

    Thanks for the fix. That seems to work for the og:description, but there must be several other places where a similar tweak to the function call parameters are needed for the meta description and the twitter description, right?

    Plugin Author George Notaras

    (@gnotaras)

    The affected files are these:

    metadata/amt_basic.php:250:            $description_content = sanitize_text_field( amt_sanitize_description( term_description( $tax_term_object->term_id, $tax_term_object->taxonomy ) ) );
    metadata/amt_opengraph.php:284:        $description_content = sanitize_text_field( amt_sanitize_description( term_description( $tax_term_object->term_id, $tax_term_object->taxonomy ) ) );
    metadata/amt_twitter_cards.php:148:                $description_content = sanitize_text_field( amt_sanitize_description( term_description( $tax_term_object->term_id, $tax_term_object->taxonomy ) ) );

    I’ll try to release the new version (2.8.5) today.

    Another thing I would like to fix is to automatically use the WooCommerce product category thumbnail in the generated metadata. Currently, this has to be done manually, but I’ll look for a generic automatic way that could work with any e-commerce solution. But I am not sure if this will be implemented in 2.8.5.

    Again, thanks for your feedback.

    George

    Thread Starter pjv

    (@pjv)

    Awesome support as always.

    Thanks George.

    Plugin Author George Notaras

    (@gnotaras)

    If you could fix the above 3 lines and confirm that everything works as expected, that would be very helpful.

    Your feedback is much appreciated.

    George

    Thread Starter pjv

    (@pjv)

    Already did and yes it does fix all the meta descriptions for both the WooCommerce product category pages as well as the standard category pages for the og:description and twitter:description.

    Plugin Author George Notaras

    (@gnotaras)

    Thanks, pjv.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Custom taxonomy archive not using description’ is closed to new replies.