• Resolved somethumb

    (@somethumb)


    Since the Section block only takes CSS classes, it’s difficult to pinpoint a section as a jump link, so it needs an ID field as well.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Presumably in this example, any section with a class that begins with jma-menu would trigger the creation of an empty div (just before it) the matching id.

    function jma_enqueue_ids()
    {
        $data = 'jQuery(document).ready(function($) {
            $(".wp-block-uagb-section").each(function() {
                    $this = $(this);
                    classes = $this.attr("class").split(" ");
                    var i;
                    id = "";
                    for (i = 0; i < classes.length; ++i) {
                        if (classes[i].match("^jma-menu")) {
                            id = classes[i];
                        }
                    }
                    if (id) {
                        jQuery("<div/>", {
                            id: id
                        }).insertBefore($this);
                    }
                });
            });';
        wp_add_inline_script('uag-script', $data);
    }
    
    function jma_uagb_template_redirect()
    {
        add_action('wp_enqueue_scripts', 'jma_enqueue_ids', 99);
    }
    add_action('template_redirect', 'jma_uagb_template_redirect');
    Thread Starter somethumb

    (@somethumb)

    Thx John, but i was talking about adding it in through the block parameters (like the classes are) so that it’s already embedded into that section.

    Plugin Support Team Brainstorm Force

    (@brainstormteam)

    Hello @somethumb,

    Unfortunately, as of now, we don’t have any way to add an ID to the section block. This feature is on our list. Our team will surely work on it and we’ll try to add this feature in our future release.

    We really appreciate your efforts and patience.

    Meanwhile, for a temporary solution, what you can do is –

    1] Take Layout Elements as Group. Screenshot

    2] Drag and drop the section in the group as mentioned here.

    3] Add the ID to the group. Refer to this video.

    I hope this helps.

    Regards,
    Sweta

    Plugin Support Team Brainstorm Force

    (@brainstormteam)

    Hello @somethumb,

    We have added an option to add an id to most of our blocks in our latest update ie ver 1.14.9, you can do that from Block Settings > Advanced > HTML Anchor

    I suggest you update the plugin to the latest version and check it out.

    Regards,
    Rajkiran

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add an ID to the Section block’ is closed to new replies.