Home>Support>Yoast Seo plugin causing widgets to be processed in inappropriate locations

Yoast Seo plugin causing widgets to be processed in inappropriate locations

By C, 7 years ago. Last reply by Alex S, 7 years ago.

I’m pretty sure this is intended behaviour rather than a bug but I thought I’d raise it in case anyone else comes across it or in case it is worth having some way of preventing it from happening in certain scenarios.

I created a widget which, as part its ‘widget’ function, adds JavaScript to the footer. I then created a page and added the widget to the page builder. When viewing the page I noticed that the script in the footer was being rendered three times instead of one.

It took me a while to realise that the WordPress SEO plugin was attempting to process the content of the widget for use in the og:description and twitter:description meta tags (adding any text content from my widget to these tags’ values). As a side-effect new scripts were being rendered in the footer, once for each tag.

The fix is simply to update WordPress SEO’s meta description field on the page in question so that it doesn’t try to automatically pull the content from the page builder. As an alternative I wondered if a provision could be made for widget authors to prevent certain widgets from being considered as page content by the Yoast SEO plugin.

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 7 years, 1 month ago Alex S
    Hi, I Work Here

    Hi C,

    This is intentional.

    As an alternative I wondered if a provision could be made for widget authors to prevent certain widgets from being considered as page content by the Yoast SEO plugin.

    I would recommend running a in_the_loop() (sidebar widgets areen’t in the loop) and is_main_query() (if it’s the main loop) check to avoid this.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More