• Hi,

    Can you add a CSS ID to the div containing the TOC so

    <div class="lwptoc lwptoc-autoWidth lwptoc-light lwptoc-notInherit" data-smooth-scroll="1" data-smooth-scroll-offset="24">

    becomes

    <div class="lwptoc lwptoc-autoWidth lwptoc-light lwptoc-notInherit" id="lwptoc" data-smooth-scroll="1" data-smooth-scroll-offset="24">

    ?

    Reason is some plugins such as Q2W3 Fixed Widget allow to define custom CSS IDs to identify elements, but not classes.

    Thanks

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author LuckyWP

    (@theluckywp)

    Hello, @nicoter !

    Is this question actual?
    In last version of plugin we added wrapper with ID to widget.

    • This reply was modified 5 years, 5 months ago by LuckyWP.
    Thread Starter nicoter

    (@nicoter)

    I see no ID, I see only a class. Also with the latest version.

    Maybe you mean the dynamic ID added to sidebar widgets?

    But there’s no ID when adding the TOC by shortcode.

    Plugin Author LuckyWP

    (@theluckywp)

    ID in wrapper of widget in sidebar, for example:

    <aside id="lpwtoc_widget-6" class="widget widget_lpwtoc_widget">
    	<div class="lwptoc lwptoc-autoWidth lwptoc-baseItems lwptoc-light lwptoc-notInherit">
    		…
    	</div>
    </aside>
    • This reply was modified 5 years, 5 months ago by LuckyWP.
    Thread Starter nicoter

    (@nicoter)

    That’s the dynamic ID added to sidebar widgets like I said in the last post. This is added by WordPress, but:

    – different depending on the order of the widget, e.g. lpwtoc_widget-6 or lpwtoc_widget-3 or lpwtoc_widget-1

    – not added when the TOC has been manually added to a page by shortcode

    Plugin Author LuckyWP

    (@theluckywp)

    If we make ID to ToC, then it will also be dynamic. ID should be unique on page.

    May be make option for set ID manually?

    Thread Starter nicoter

    (@nicoter)

    There’s no need for it to be unique on a page level. The body tag contains already a unique class per page/post, e.g. postid-3514. So if anybody wants to address the ID on a specific page he can do it by combining the unique class and static ID.

    The ID should be static in the wrapper just like the lwptoc class is right now. It’s just needed because there’s other plugins which can only address elements with IDs, not classes.

    Plugin Author LuckyWP

    (@theluckywp)

    But ToC may be several on one page and their ID should be different. So ID will have to do dynamic.

    Thread Starter nicoter

    (@nicoter)

    The lwptoc class is not dynamic as well. Why should the ID be?

    If somebody needs to address a specific instance of the TOC, he can use the CSS selectors nth-child or nth-of-type.

    Thread Starter nicoter

    (@nicoter)

    Or you can add two ID’s, e.g.:

    "lwptoc lwptoc-1"

    Plugin Author LuckyWP

    (@theluckywp)

    Because ID should be unique: https://www.w3schools.com/html/html_id.asp

    Thread Starter nicoter

    (@nicoter)

    Thanks for the link, I wasn’t aware of this.

    Well in this case you’re right, it should be unique for each instance of the TOC.

    Since I typically have only one instance per page, this should be no problem to use the ID as a selector for other plugins. But it’s a little bit harder for you to implement it.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Add CSS ID to container div’ is closed to new replies.