Front-end / back-end render_template different

Support MB Blocks Front-end / back-end render_template differentResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17603
    Key_WebdesignKey_Webdesign
    Participant

    Hi there,

    I have made a custom Block with MB Blocks which presents a loop of custom posts. In the output of this block are many link tags (<a>), which is pretty unwanted in the Gutenberg editor itself, because you can now click on items in the Gutenberg editor itself, redirecting the entire page to the permalink...
    I would like to remove these link tags in the back-end (admin) mode and replace them with, for example, <div> tags.

    Now I tried to use both the render_template and the render_callback function but this does not work.

    Is there a way to get this to work?

    #17615
    Anh TranAnh Tran
    Keymaster

    Hi, have you tried using the $is_preview parameter for the render_callback and render_template? It allows you to render the block differently on the back/front end.

    #17633
    Key_WebdesignKey_Webdesign
    Participant

    Hi!

    I have tried something, but that didn't work.
    Do you have an example code for this function?

    #17644
    Anh TranAnh Tran
    Keymaster

    Here you are: https://pastebin.com/RKpbnYa3

    #17650
    Key_WebdesignKey_Webdesign
    Participant

    Yes, that did the trick!
    Thanks a lot!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.