• Resolved Mark Wilkinson

    (@wpmarkuk)


    I have been working on a site using the render_block filter to add some code before each block is output on a page. In this case using wp_print_styles() to output a link to a stylesheet.

    I noticed that this didn’t work for specific core blocks. Someone mentioned that it could be this plugin and sure enough when I deactivate this plugin my function works perfectly.

    It is almost as though the blocks are rendered twice, once my this plugin and then once on the page as usual. The 2 passes are causing a problem.

    I was wondering whether you know if this is the case or not and if so how it can be fixed please?

    Many thanks for your time in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @wpmarkuk,

    We’re sorry to hear that you’re seeing an error when using Yoast SEO and the render_block filter. Can you share with us some example code that we can use to reproduce the problem?

    Also, just to be sure that there isn’t another issue causing the problem, we’d like to gather the information below:

    1. Are all your plugins and themes updated? If not, does updating solve the problem?

    2. Are you using the latest version of Yoast SEO {16.0.2)? If not, does updating solve the problem? We have update instructions available in this guide: How can I update my (free) plugin?.

    3. Do you see any JavaScript errors in the browser console?

    4. Check your PHP error log for any error messages. You can do this by enabling WordPress debugging or contact your web host.

    5. Does clearing your cache from caching plugins, the server, a CDN like Cloudflare, or the browser resolve the issue? If you are not sure how to clear the cache from a plugin, please contact the plugin author. If you’d like to clear the cache from the server, please speak to your host provider. To clear the cache from a browser, use this guide: How to clear your browser’s cache.`

    Thread Starter Mark Wilkinson

    (@wpmarkuk)

    Hi Priscilla,

    Thanks so much for getting back to me so quickly – I really appreciate you trying to help.

    I have created a test environment locally to test this out in a more controlled install of WordPress.

    I have a fresh install of WordPress 5.7 running the Twenty Twenty One theme and just the Yoast SEO plugin installed, nothing else.

    I then have the following code running, as a single file in the mu-plugins folder.

    https://gist.github.com/wpmark/effd64687c09f62987d24e317fbccbab

    I have added paragraph.css and image.css to the active theme in the correct locations referenced in the mu-plugin.

    With the Yoast SEO plugin turned on, I don’t get a paragraph.css file link output above paragraph blocks, but I do get an image.css file rendered.

    Deactivating Yoast SEO means the functionality works as it should.

    There are no PHP error or JS errors in the console.

    It is like the paragraph block is already rendered before the page is rendered and therefore it on that pass of the render_block filter that my code has actioned.

    Thanks for sharing all the information with us @wpmarkuk. While we are exactly not sure why Yoast SEO is preventing the render_block filter correctly as expected, we can definitely investigate the issue further for you to see if this is something that can be fixed from our end.

    In this case, we recommend you please submit an issue report directly at GitHub development repository with all the information you have described above including the Gist so that our development team can reproduce the issue and will get back to you soon.

    We can only offer basic support here and your queries need a developer to take a look at from our team.

    Thanks for your understanding!

    We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Plugin causing render_block filter to run more than once per block’ is closed to new replies.