• Resolved s-light

    (@s-light)


    Hello Community,

    is there any option to include *pre-designed* Reusable blocks in an (child) Block Theme?
    i know i can export theme as json file.
    but did not find any hint in the documentation if / how i could include it in my theme..

    any ideas are welcome ??

    sunny greetings
    stefan

    • This topic was modified 1 year, 5 months ago by s-light. Reason: add greetigns
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter s-light

    (@s-light)

    read some more…
    Reusable blocks are done via a custom post type and i think that answers my question: iam not able to create a custom post from a theme..
    so i will revert to just use a block pattern with the *default* content. and leave it open the the user to convert it to a Reusable block.

    or is it possible to create a custom post from/by a theme?

    sunny greetings
    stefan

    Moderator bcworkz

    (@bcworkz)

    Your theme could insert a new post of any type on activation. It can insert a reusable block post by simply specifying the correct post type as part of wp_insert_post() parameters.

    When someone edits a reusable block, that edit will be applied to all instances of that block anywhere in your site. Is that what you want? If not, I think you might want to use a block pattern instead?

    Thread Starter s-light

    (@s-light)

    thanks @bcworkz yeah that is what i want..
    it is a block-group for a newsletter section…
    and i incorporated a *styled-warning-sign* to highlight that all edits will change this on all sites…

    
    /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
    /* hacky tweak for reusable blocks editing    */
    /* based on https://www.ads-software.com/support/topic/make-it-less-easy-to-edit-reusable-blocks/#post-14525041 */
    /* .wp-block:not(.is-reusable) {
    	border: 1px dashed #ddd;
    } */
    .block-library-block__reusable-block-container {
        background-color: hsl(300, 100%, 50%);
    	box-shadow: 0 0 3px 3px hsl(300, 100%, 50%);
        border: 3px dashed hsl(180, 100%, 50%);
        padding:1px;
    }   
    .block-library-block__reusable-block-container > * {
    	pointer-events: none;
    }
    /* .wp-block.is-reusable .wp-block:not(.is-reusable) {
    } */
    .block-library-block__reusable-block-container.is-selected::before,
    .block-library-block__reusable-block-container.has-child-selected::before {
    	content: 'Rusable Block – Be Careful with editing! → this changes all occurrences of the block.';
    	font-weight: bold;
    	font-size: 20px;
        padding: 1rem;
    }

    my i think that should work curiosity is often a bit to active ??
    as it is just a one-shot client theme (only this customer will use it..)
    for now it is to much additional work.

    Thanks for your pointers!!

    sunny greetings
    stefan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Block Child Theme: include pre-designed *Reusable blocks*’ is closed to new replies.