• vixperth

    (@vixperth)


    Is it at all possible to override the existing gutenberg block templates? For example if I have WooCommerce on my site, I can override the templates by copying them into my theme. Is there an option to do this with the blocks for gutenberg? Or extend the blocks in some way?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you’re referring to the template files used to present the pages on a WordPress site, nothing changes with regards to Gutenberg. WordPress still uses the same template hierarchy — single.php for individual posts, page.php for pages, etc.

    The editor ((Classic, Gutenberg, or some other page builder plugin) merely helps with the laying of the individual elements forming the page (paragraph here, headline here, image there, etc) but has nothing to do with the overall presentation of the page.

    See Template Hierarchy:

    https://developer.www.ads-software.com/themes/basics/template-hierarchy/

    And an interactive diagram:

    https://wphierarchy.com/

    Moderator bcworkz

    (@bcworkz)

    I think you can override the JS portion of the block functionality, though I’ve never tried it myself. The key would be to ensure your JS is loaded on the editor screen after the default JS. In PHP hook “admin_enqueue_scripts” with a very large priority argument to enqueue your JS script file.

    Failing that, you can always define your own custom block based on code from an existing block. See https://developer.www.ads-software.com/block-editor/tutorials/block-tutorial/writing-your-first-block-type/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Override Core Gutenberg Block Templates’ is closed to new replies.