Questions tagged [widgets]

Widgets are configurable elements used to dynamically build sections of a WordPress theme.

576 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
2 answers
2k views

How to refresh Theme Customizer after change color inside wpColorPicker?

I develop my custom widget with setting where I can set up custom color for the widget. I use this code to initialize wpColorPicker instead of default text input in form() method of Widget class: ...
Kolya Korobochkin's user avatar
5 votes
1 answer
2k views

How to add image uploader to a custom widget?

I'v built a custom widget that will show some sport scores. Scores are added trough custom post. When i open new custom post(scores) i enter their team names, score, scores. Now i want to add an ...
Max's user avatar
  • 129
3 votes
0 answers
52 views

Get widget settings function?

I am using this to find if a new widget has been added or removed from my site: serialize(retrieve_widgets()); Works great for added or removed widgets. But it doesn't detect if a widget setting has ...
joq3's user avatar
  • 371
3 votes
0 answers
36 views

How to enable / use new video / audio / images widgets in WordPress 4.8?

I've read here that you can now add video widgets, but I cannot see the option on my Widgets page. Can anyone advise how to enable/use it?
ban-geoengineering's user avatar
3 votes
0 answers
492 views

iris color picker in widget - click event doesn't fire when initially when widget is first created

I added the wordpress(iris) color picker to a widget, and the color picker is not clickable when the widget is first created. My guess is that it's where/how the javascript file is being enqueued, but ...
scendo's user avatar
  • 81
3 votes
0 answers
534 views

Widget area inside a widget

I tried putting dynamic_sidebar('widget-id') inside a custom widget I created and it worked. The only thing I can't figure out is how I can do this through a loop. Is there a way that when the widget ...
Joveth Gallardo's user avatar
3 votes
2 answers
793 views

How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?

I added the following to my functions.php: add_action('pre_get_posts', 'keyl_get_emp_posts'); function keyl_get_emp_posts($query) { if ($query->is_main_query()) $query->set('...
Ana Ban's user avatar
  • 797
3 votes
1 answer
325 views

Ask user permission when activating a plugin

Is there a specific Wordpress API way to ask the user's permission for something when activating a plugin? Due to the Wordpress plugin directory policy I have to ask the users consent for the ...
Owl's user avatar
  • 221
2 votes
0 answers
401 views

How do I remove/reset all current widgets from the database?

I recently migrated a site from a dev server to a web server and I appear to be stuck with a menu sidebar I had built in the old site that doesn't appear in the widget area of the new site's dashboard ...
ProverbialPaul's user avatar
2 votes
0 answers
147 views

How to disable Widget Gutenberg Blocks?

I was looking for how to deactivate the widget blocks that appeared with version 5.8 of Wordpress and I couldn't find it here. As I found the answer elsewhere, I share it here. So, to disable widget ...
dragoweb's user avatar
  • 249
2 votes
0 answers
103 views

Custom widget select options needs to stay selected after save

I am working on a custom widget that includes a select options drop-down list of pages. When I select a page and save, the selected option does not stay selected. However, if I refresh the widgets ...
osxxso's user avatar
  • 21
2 votes
0 answers
732 views

Add Icons to the Product Category Sidebar Widget WooCommerce

I have been searching for this since yesterday. It's weird the little info is there about this simple function, I suppose that's because the answer is too obvious. But I didn't find the way to display ...
Sin Medias's user avatar
2 votes
2 answers
447 views

Is there a way to extend the default image widget into a new custom widget and add additional fields to it?

Ultimately I'm wanting to add some custom widget fields to the existing default image widget, and define it as a new custom widget. I'm trying to create my own by extending the WP_Widget_Media_Image ...
Timothy Fisher's user avatar
2 votes
0 answers
162 views

How to get sidebar's content inside admin-ajax?

I'm using a modal to display some content via an admin-ajax request. Now I have problem outputting the content of a sidebar (text widgets, used for adding advertisement scripts). When I directly use ...
Johansson's user avatar
  • 15.1k
2 votes
0 answers
178 views

How to create another version of the Category widget?

I need to handle both Brands and Categories in WordPress. So I thought I would create a new copy of the Category widget – just with Brands. I've tried various workarounds, including tags, custom ...
Sam's user avatar
  • 49
2 votes
0 answers
232 views

Trouble with switch_to_blog()

My WordPress environment is set up with 1 main site and many "sub" sites. They all have the same theme. Lambda by Oxygenna if that matters. I'm trying to centralize management of the footer so if ...
johnlxc's user avatar
  • 21
2 votes
1 answer
79 views

How to create custom field in worpdress default widgets?

I want to create custom dropdown field with CSS animation settings, that would add different CSS classes to the Text Widget <div>. I've done this for third-party widgets, but I can't imagine ...
A. Korolev's user avatar
2 votes
1 answer
2k views

woocommerce featured products and categories

I am working with woocommerce at the minute, and the design requires to show a number of featured products and categories in a number of different styles. For example one featured product needs to ...
sico87's user avatar
  • 209
2 votes
0 answers
4k views

Widget page is missing from menu and default widgets are not showing

Necessary background information: I'm working on a website which were first developped by an other web agency. So I don't have all of the history of the project. I have an issue with a Wordpress ...
vard's user avatar
  • 143
2 votes
1 answer
164 views

How can I reuse the Wordpress search form for a custom plugin / widget?

I need to develop a custom widget to display posts, based on their ID. The user must be able to handpick posts. Right now, they can enter the post ID, but it is not convenient for them. Is it ...
pixeline's user avatar
  • 2,837
2 votes
0 answers
26 views

Custom Widget form function common elements

I am writing a set of custom widgets, all of which share a common 18 lines of code in the form() function, which looks like this: <div class="common-section"> <input type="hidden" class="...
Moose's user avatar
  • 292
2 votes
1 answer
388 views

Updating Widget options in custom install.php

I am using a custom install.php in /wp-content/ to over-ride some defaults when creating sites in a multi-site install. For the most part, this is easy and working really well. I am having difficulty ...
verdonv's user avatar
  • 21
2 votes
1 answer
61 views

Including Custom Post Type posts in a page template contextually (or should I widget?)

Please see the attached mockup… Each element in the sidebar (e.g., Communications) will probably have to be a Page. I'm aiming for maximum flexibility. I am using Epik (a Genesis child theme). I ...
Lorin Rivers's user avatar
2 votes
0 answers
368 views

Admin Dashboard with Custom Tab for Client

I am trying to create a basic Tour Date widget. When the user clicks on the Tour Date Tab from the admin dashboard I want them to be presented with five fields. Date Venue City, State or Country ...
Polemistis D'Gnosis's user avatar
2 votes
1 answer
300 views

Insert Widget option into mark-up with register_sidebar

I have added a custom field to my all widgets in my theme, called "custom-title". I have managed to save the field into the database for each widget, like so: s:12:"custom-title";s:17:"HELLO TEST ...
Ila's user avatar
  • 121
2 votes
2 answers
2k views

Multisite Widget/Content

I'm using WordPress multisite and need to display content across all subsites in the sidebar. This is a network of 50+ sites so updating all 50+ sidebars with this content every few days is not ...
Andrew's user avatar
  • 21
2 votes
1 answer
85 views

Why won't my custom widget stay in the sidebar after a reload?

After I drag my custom widget into a widget area and reload the page it's gone. Any ideas? <?php add_action('widgets_init','register_postTypeWidget'); function register_postTypeWidget(){ ...
dcp3450's user avatar
  • 455
2 votes
2 answers
2k views

Full width layout for custom post type pages

I'm trying to remove a widget area called 'Primary' from a certain page on a site. This is the function where I manage the sidebars: //ADD CATEGORIES IN SIDEBAR OF SINGLE POST TYPE add_action( '...
Damon's user avatar
  • 275
2 votes
1 answer
243 views

Passing $this->get_field_name() to javascript

I've tried doing this one of two ways: In the form method of my Widget class (which extends WP_Widget), I have the following snippet, which sets a global javascript variable: if( $instance ) : ?> ...
Kurt's user avatar
  • 179
2 votes
1 answer
426 views

Trying to wrap <span> around first word of multiple word strings with a widget_title() filter, only works on two word strings and not more than two

I am trying to wrap a around the first word of multiple word widget titles. I have used the answer from here: https://stackoverflow.com/questions/10263792/revised-wordpress-function-to-put-a-span-...
Leon Francis Shelhamer's user avatar
2 votes
1 answer
96 views

add widgets to dashboard for easy access for clients?

I have a widget created: if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Featured Video', 'before_widget' => '', 'after_widget' => '', '...
Desi's user avatar
  • 1,199
1 vote
0 answers
18 views

Add custom settings to widget areas

I'd like to add settings to sidebars defined in my custom theme - sometimes, for example, I'd like to be able to set a widget area to not display. Is this possible, I can't find any references for it?
toby1kenobi's user avatar
1 vote
0 answers
39 views

Footer option is missing in Customiser

Below is my dashboard screenshot, I don't see the footer option in my customizer. I have struggled a lot to research on this but no luck. Can anybody please help me with this? how can I show the ...
ss-ss-v1's user avatar
1 vote
1 answer
99 views

Unable to locate inline CSS causing parts of page to be blank

Large parts on a live Wordpress page shows blank because a piece of inline CSS has opacity set to 0. Unfortunately I am unable to find where this inline CSS lives. <div class="grve-element ...
bart's user avatar
  • 205
1 vote
1 answer
208 views

isSavingPost() for widgets

I want to get the block ID of my widgets (e.g. #block-1, which is displayed on the frontend after saving a widget) on the widgets screen in the backend. What I try to achieve is to display the ID of ...
KittMedia's user avatar
  • 179
1 vote
0 answers
102 views

How to check if a WordPress core block is active in sidebar

I have a widget area and I want to enqueue a stylesheet only if a core block is active in it. I tried the following code: // if has audio block. if (has_block('audio')) { wp_enqueue_style('audio-...
Zeddy Emy's user avatar
1 vote
1 answer
207 views

Is there any way to parse blocks inside widget area?

As widgets are outside post content, i couldn't find the way to parse blocks inserted inside widget area for ex. "sidebar-1" We use something like below for parsing post contents, $post = ...
Thirumani guhan's user avatar
1 vote
2 answers
1k views

How a HTML form can trigger a PHP function?

I'm new to the Wordpress/PHP world. I want my page be able to communicate with an API that I build myself. So for this I have a form on my Wordpress Page using a HTML code widget which looks like this:...
dsenese's user avatar
  • 11
1 vote
0 answers
21 views

Save Widget State Between Theme Swaps?

I made my own custom sidebar widgets in my custom theme's functions.php file.. I noticed that when I swap my theme and then swap back, one of my sidebar loses it's configuration and I have to go in ...
Cmaxster's user avatar
  • 111
1 vote
0 answers
1k views

Your theme has 8 widget areas, but this particular page doesn’t display them

CUrrently I downloaded one wordpress theme. In few pages i have widget area . But i want to display in one more page. On that page i am getting message inside customize->widget as "Your theme ...
Praful's user avatar
  • 11
1 vote
0 answers
65 views

Adding custom field in all widgets, but at the top of the form, in admin area

I am creating a cute new functionality on my theme that requires to add a custom field to all widgets forms in the admin area. I managed to do so by using the in_widget_form hook: function thefunction(...
Gerardo Peña Pérez's user avatar
1 vote
1 answer
121 views

Ajax contact form widget plugin data not insert in database

I have been working at this for weeks without success. I've figured out problem after problem with the code, but none of the corrections seem to fix my core problem. The form doesn't insert anything ...
dhanar98's user avatar
1 vote
0 answers
28 views

Getting a div wrapped around two widgets

To get the layout I'm looking for, I (think that I) need to get a div to surround two of the three widgets that I am placing in a widget area. Is there a way to do this without making a new sort of ...
bmargulies's user avatar
1 vote
0 answers
100 views

How to extend WP_Widget_Media

I am new to WordPress theme development. I'd like to create a new widget based on the built-in Image widget, with additional fields such as 'description' & 'speaker'... etc. The widget is called '...
brian's user avatar
  • 111
1 vote
0 answers
68 views

List of JS Events for Widgets?

Does anyone know if there's a list of all JavaScript events for widgets? I know there are other lists (e.g. Woocommerce; wp.media) but I'm looking for one specifically for widgets. It took me a bit of ...
DaveyJake's user avatar
  • 143
1 vote
0 answers
109 views

How do I change the markup only of a built-in widget?

I'm developing a theme and I'd like to slightly alter some of the HTML output of some of the built-in widgets. As of now, I managed to change the sidebar search widget by creating a searchform.php ...
Morpheu5's user avatar
  • 111
1 vote
1 answer
878 views

How to add multiple footer widgets?

I am new to WordPress. I would am currently using the Twenty Seventeen Theme. I would like to add multiple Footer Widgets, however WordPress is limiting me to only two. Is it possible to add a few ...
Developer's user avatar
1 vote
0 answers
46 views

Is it possible to make widget return only data (eg, array)?

I want to make widget to return only data (array variable). Here is the code of my widget custom class: class ContactInformationWidget extends WP_Widget { function ContactInformationWidget() { ...
Evgenij's user avatar
  • 11
1 vote
0 answers
57 views

How to add media field to WP_Widget form function?

I am creating simple WP_Widget plugin and I want to add one filed to form function inside it. I want to allow user to pick some photo from wordpress media. I know how to implement input text, textarea ...
Freestyle09's user avatar
1 vote
1 answer
63 views

How to output only blockquotes content from recent posts in a widget?

I created a simple widget that displays recent post titles. How can I only display the content that is between < blockquote >< /blockquote > from recent posts? For example, all my posts have a ...
Knott's user avatar
  • 454

1
2 3 4 5
12