Home Forums Backend Issues (wp-admin) ACF Blocks to Specific WP Templates without page refresh


ACF Blocks to Specific WP Templates without page refresh

  • Hello,

    Been trying to assign specific ACF blocks to certain WP templates the thing is when template is changed from WP Dashboard a page refresh is necessary which isn’t very user friendly looked into a lot of options where I was able to deregister and also remove the blocks using JS with

    removeBlockTypes(‘blocksArray’) and also tried wp.blocks.unregisterBlockType(blocksArray);

    it works fine when a template is changed via WP dashboard without a refresh where they both remove the blocks properly from blocklist menu but the issue I have it re-adding the blocks that belong to the new template

    wp.blocks.registerBlockType(allowedBlocks); seems to be adding a new block

    and addBlockTypes(allowedBlocks); doesn’t seem to be working with ACF Blocks

    Another approach was to add custom css classes to the ACF blocks within the Block Items list so that they can be used to trigger those blocks visibility as per to the template selector on WP dashboard without a page refresh being necessary but I couldn’t seem to figure a way of doing it either with ACF blocks nor default ones. Is there a way to do this?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.