Solved it by following the advice from @mmm. Using $args["id"]
did the trick.
Using $args["id"]
will return the following:
post-sidebar
footer-first
With a little change, my final code is:
public function widget( $args, $instance ) {
extract($args);
// ...
<div id='instafeed-<?php echo explode("-", $args["id"])[0] ;?>' class="c-widget-instagram"></div>
<?php
echo $after_widget;
}
The result is:
<div id='instafeed-post' class="c-widget-instagram"></div>
<div id='instafeed-footer' class="c-widget-instagram"></div>
Thanks
Related Posts:
- Dynamic content in a widget
- Add a class to a dynamic sidebar’s wrapper
- Minimum Widget Width for Plugin Development
- How to show multiple instances of the WP125 Widget?
- wp_register_sidebar_widget in loop within a plugin?
- Custom Widget function in Plugin not working?
- Adding Widget form fields dynamically
- What is the correct way to build a widget using OOP
- Widget development – Drop down options won’t save
- Calling the widget id of a mult-instance widget from inside the widget?
- Is There A Hook To Process The Content Of The Text Widget?
- Add content to widget title in admin area within the widget?
- Has anyone managed to integrate the wp_editor inside a widget?
- Help adding image upload functionality to widget
- Using preg_replace to clean widget output HTML
- Edit the output of wp_widget_rss_output()
- Script to remove all inactive widgets?
- Possible to preset a widget’s contents via a plugin script?
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- How to add multiple copies of a widget from “available widgets”
- Install widget on plugin activation
- Using Ajax call in jQuery doesn’t work in widget
- WordPress select dropdown list in widget
- Using $wpdb object in a widget
- Is there a need to do apply_filter(‘widget_title’, $instance[‘title’]) or any other ‘widget_xxx’ filters?
- How to pass custom options from widget form to widget update callback?
- Broken markup when using the_excerpt() in a widget?
- Tips for targeting widget dragable for WP Pointer on widgets.php page
- How to create custom field in worpdress default widgets?
- PHP 7 – Class Method Compatibility Issue
- Widget Admin – Form Submit Event?
- How to save WP widget instances and options
- Can I individually style items in the backend widget list?
- Sidebar widget to show popular post not working?
- Widget update function not saving values
- Customizer: widget-synced triggers twice
- Widget is to be compatible with all themes
- Widget Dropdown doesn’t working
- How do I get the sub categories of the parent when in a sub category?
- How to limit number of number of categories displayed by categories widget
- Input in plugin widget does not allow spaces
- Get draggable widgets on Edit Post page
- Dynamically creating classes for Widget API
- Widget options are not updated
- Why does my widget break other widgets?
- CSS not affecting widget output
- Using a multiple element in widget form
- Problem with saving checkbox values with WordPress Widget API
- Remove sidebar on single page using plugin API
- Are there any official or unofficial guidelines for the styling of a widget?
- Create Widget or Enable Shortcodes in Sidebar
- Widget’s container?
- How to create a wordpress widget that dynamically changes according to the page
- WordPress dynamic widget by location?
- Can / should a widget plugin define its own Widget Area?
- How to exclude categories from get_categories() select list inside a widget admin panel
- Widget internal hooks and functions
- My plugin creates custom widgets, How can I programatically add them to existing sidebar widget areas?
- Console errors in 6.0-RC1 Widget screen
- Error code when migrate
- Replace Content of Sidebar on Custom Post Type
- How does update method in Widget class saves $instance array from Select tag?
- Quick Draft widget (dashboard.php) using custom post_type
- Uncaught Error: Call to undefined function wp_get_current_user() in
- Load script on frontend from widget plugin
- Can’t get wpColorPicker to work in a widget
- If user is logged-in display/hide widgets ( siteorigine) [closed]
- Set widget icon in Customizer?
- How to embed or integrated a custom WordPress Widget into the theme?
- Widget won’t be activated
- Dynamic sidebar areas not working on the Theme Customizer
- Downloading Generated XML File
- Detect each active instance of a widget
- Calling dynamic_sidebar in plugin gives error
- grouping my widgets wordpress
- Get fields of a widget
- How do I create Widget within plugin that uses its own class?
- Best practice to include custom user styles in widgets
- How to specify widget order or css name via script?
- Is it possible to add Custom Dashboard Widgets to Custom Admin Menu Page?
- Why are my widgets not saving when being added to a sidebar?
- Get list of available wordpress actions
- How can i list current author’s categories?
- Add Post and Comments menu no longer visible
- searchform.php override not working
- How to fix this URL error in WordPress ” data-wplink-url-error=”true”>
- Edit Images From the Front End without Access to WP Admin
- How to remove or add submenu item on plugin activate or deactive
- making a plugin that moves other plugins wp_head actions to wp_footer
- How to redirect to login page when user not loggedin on a particular page
- Checking for existing title in custom db query not working
- How to add a new taxonomy link to the admin menu
- Many Single Sites, One Plugin directory – adjust plugins_url()
- insufficient permissions; coding an action for plugin governed by custom capability
- How to add chunk of php, html, and sql code to variable an append to $content
- edit-tags.php in plugin admin menu hides when is the active page
- Best way to handle a form post in plugin
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Remove text from confirmation message
- Can I use an array to create multiple tables?