Custom Fields
Re-Envisioned
Support MB Blocks How can I use the custom asset callback to render a block properly?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #24478
    Long Nguyen
    Moderator

    Hi Cristian,

    You can put all JS code to the file certificaciones.js to enqueue for this block or use the code to enqueue more JS files. Follow this document https://docs.metabox.io/extensions/mb-blocks/#enqueue_assets.

    #24482
    Cristian A.
    Participant

    Hi Long, Thank you for your help.
    I was reading the documentation and I tried to use some custom assets on the block render area (using the AIO plugin) I can’t get it work correctly.

    Block render settings

    When I did a preview of the code I saw that the functions() is displaying as a string and not outside of that string to call more assets.

    Code preview

    Do you have some ideas that can I use to solve that?

    Thank you

    #24487
    Long Nguyen
    Moderator

    Hi,

    To use the custom assets in the Builder, you need to add your function code to the file functions.php in the theme/child theme folder.

    Ex:

    function my_callback() {
        wp_enqueue_script( 'my-script', 'link-to-js-file', [ 'jquery' ], '', true );
    }

    then add the function name to Custom assets callback input. Screenshot https://share.getcloudapp.com/yAu60e2J.

    #24504
    Cristian A.
    Participant

    Thank you very much

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