I believe @One Trick Pony was right.
Shortcode widgets have no ID, so I’ve found a way around.
Firstly I used PHP rand function:
$var = rand();
And then added the “var” to the ID, so it doesn’t collide with other shortcodes calling the same widget (each one has different random number at the end of the ID):
<div id="myWidget-<?php echo $var?>;"></div>
Related Posts:
- Programmatically add widgets to sidebars
- Loading scripts only if a particular shortcode or widget is present
- Limit number of Widgets in Sidebars
- Give Editor Access To Sidebar
- Where is the content of widgets stored in mysql table
- Translate widget titles using qTranslate plugin
- Get number of widgets in sidebar
- How Do I Add Custom CSS To Only Certain Widgets
- Add the sidebar/widget editor to the post edit screen?
- Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?
- Get sidebar parameters (before_widget, before_title, etc.) from within a widget
- Different widgets on different page templates?
- Widgets not displaying in theme customizer
- $post>ID displays wrong post ID
- Register multiple sidebars
- How to add author details in the post sidebar?
- Determining a Widget Instance and Sidebar Location?
- Randomize widgets displayed in my sidebar [duplicate]
- Video Embed in Sidebar Widget with Links to Others in Category
- Shortcode from a widget is wrapped in unwanted element
- Remove All Widgets from Sidebar
- Add div class to only one widget
- How can I whitelist only specific shortcodes for processing in text widgets?
- Unregistering a Sidebar in Child Theme
- Add a select box to all widgets
- Problems with the sidebar args and wp_list_bookmarks
- How to avoid widgets added to sidebar on theme activation?
- Ban certain widgets from certain sidebars
- When to use which plugin output method?
- Manual display of widget
- Sidebar Widget Registration without a name, how is it assigned to new named sidebar widget?
- Custom shortcode in widget forced to top of widget
- is_active_sidebar() Always Returns False
- Call sidebar from a template
- How could a Widget behave differently depending on sidebar
- Adding classes to dynamic sidebar
- Is there a way to allow only certain type of widgets in the sidebars?
- Shortcode in Text Widget not working
- Inserting shortcode [stream /] into a Text widget
- Display sidebar that created in functions.php
- Create variable from widget instance
- Save/update widget outside admin panel [closed]
- WordPress: Apply filter/hook to a particular sidebar widgets?
- How to insert widget areas specific to certain pages (or posts, etc.)?
- check for shortcode in post/pages AND widgets AND template files
- List sidebars on a page
- Why use dynamic_sidebar() conditionally?
- wordpress widget textbox in the sidebar
- WordPress Widget multiple use
- Contact Form in sidebar [closed]
- More flexible sidebar and widget management
- WordPress widget new instance creates content duplicates
- dynamic_sidebar() returns false in admin section
- duplicate sidebar
- How to check if searchform.php is being included as widget?
- How to get sidebar’s content inside admin-ajax?
- Removing custom widget area WordPress 4.4 [closed]
- Insert Widget option into mark-up with register_sidebar
- Full width layout for custom post type pages
- How to “pair” two widgets side by side in one sidebar [closed]
- How the widget can be run by shortcode
- Adding custom html and standard widgets to sidebar
- Dynamic Sidebars On Multiple Subpages
- How to add new sidebar widget area to child theme?
- Cannot save widgets in custom sidebars
- Check which registered sidebar a widget is added to
- How do i display the built-in gallery inside a widget?
- Disable widgets on specific posts
- Shortcode displays always first. Once again
- Display the id list of active widgets of same sidebar?
- How to remove a widget from the sidebar on specific page?
- Add individual tag to widget title in sidebar
- Excluding specific widgets from default sidebar class
- Can WordPress Read Its Own RSS Feed?
- different class (css) for sidebar widgets
- Can’t see widget areas in my customizer
- Create a widget to use shortcode?
- Check if the current shortcode is being used in a widget
- Display custom widget, added as a shortcode in the correct place
- Dynamic sidebar based on category
- Widgets not activated alert after using get_sidebar()
- How to show different widgets on different pages in a user friendly way
- Show widget differently depending on if it’s in the sidebar or footer
- How can I assign widgets from WP to appear in bbpress?
- How can I get the first section of a page 100% width, while the rest will have a sidebar? [closed]
- Trying to create dynamic widget area using post ID
- Can you target a widget_class in a register_sidebar?
- How to create pagination for homepage with widgetized area?
- Dynamically add content to an existing widget area
- Allow shortcode for custom widget
- How can I inject html after the [x]th widget inside a Sidebar? [duplicate]
- Default widgets assignment – isn’t working
- Copy Widget Settings because of changed IDs
- Programmatically add widgets to sidebars
- Programmatically add widgets to sidebars
- Programmatically add widgets to sidebars
- How to call widget by widget’s id?
- Override WordPress Widget CSS Classes?
- Are widgets meant to be used outside of sidebars?
- wp_get_attachment_image() not displaying post images even though wp_get_attachment_url() echo correct urls