Questions tagged [widgets]
Widgets are configurable elements used to dynamically build sections of a WordPress theme.
168
questions
99
votes
7
answers
18k
views
Where to put my code: plugin or functions.php?
Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s functions.php?
There are many cases and many debates about that topic, mostly because there are ...
95
votes
3
answers
43k
views
Between functions.php (theme), widgets, and plugins, which is loaded first?
Customer asks if a specific carousel plugin he uses can be widgetized. That means I should create a widget inside functions.php which calls the plugin's function. That means that the plugin's code has ...
71
votes
4
answers
38k
views
Programmatically add widgets to sidebars
I would like to programmatically add widgets to my two sidebars that I've got. I couldn't find any official way of doing it?
I started looking in the database. I've found that it's the '...
15
votes
4
answers
6k
views
Update widget form after drag-and-drop (WP save bug)
I've posted a bug-report about this a few months ago (on WordPress trac (Widget Instance Form Update Bug)) and I thought I'd try writing about it here too. Maybe someone has a better solution to this ...
17
votes
4
answers
16k
views
Loading scripts only if a particular shortcode or widget is present
I needed a way to filter a page/posts content before it was loaded so I could add scripts to the header if a specific shortcode was present. After much searching I came across this on http://...
17
votes
4
answers
8k
views
Limit number of Widgets in Sidebars
If I use a custom widgetized area (for example footer) where there is only a limited number of spots for widgets (by design), can I limit the number of widgets the user may include in that specific ...
11
votes
2
answers
12k
views
How to store widget fields data as an array?
I am creating a widget, it needs to store about 10 IDs. Right now I'm using following field method to store each of the ID in a separate field. It stores data of each field in a separately in the ...
10
votes
3
answers
5k
views
Custom Post Type Data in Sidebar widgets?
(note: this question was originally about Custom Fields, but @MikeSchinkel had a better solution involving Custom Post Types)
On my site I have several pages which I want to show the same data in the ...
7
votes
4
answers
47k
views
How to add a specific widget to only 1 page?
I would like to show a widget in only one page of my site, as i can see it is not possible right?
Should i add that for all my site pages or not?
5
votes
2
answers
6k
views
Is There A Hook To Process The Content Of The Text Widget?
Is there any filter which can be used in a plugin to process the content of the text widget before it is rendered?
25
votes
2
answers
8k
views
Wordpress 3.8 - Dashboard 1 Column Screen Options
With the new Wordpress 3.8 under Screen Options they seem to have misplaced the "Columns" feature where you could put your widgets into 1 Column, 2 Columns, 3 Columns, or 4 Columns. My question is how ...
21
votes
2
answers
6k
views
Executing Javascript When a Widget is Added in the Backend
I have widgets that have javascript controls attached to them.
If the widget is present when the widget admin page loads, the controls work correctly.
When I add a new widget, they do not work ...
6
votes
3
answers
2k
views
Call dynamic_sidebar but include/exclude named widgets?
Is it possible to include or exclude specific named widgets that are assigned to a named dynamic_sidebar call?
For example, if I've registered a sidebar named "my_sidebar" and the user had placed a "...
5
votes
1
answer
1k
views
Highlight custom widgets in the admin area?
I have created some custom widgets for my client to use, but I want to make them stand out amidst the fifteen or so standard widgets in the admin area. How can I do this?
I have solved this problem ...
4
votes
6
answers
16k
views
Widgets not displaying in theme customizer
I am developing a new theme and I am using several sidebars in this theme. All works fine, but the widgets are not showing up in the theme customizer section. All widgets are working fine under "...
4
votes
1
answer
2k
views
How to add author details in the post sidebar?
I would like to add author details in the sidebar instead of bottom of the post?
Can anyone tell me how to do that?
As of now i'm using like this in the loop
<?php $curauthor = ...
3
votes
3
answers
11k
views
Why Can't wp_editor Be Used in a Custom Widget?
I've been working on developing a plugin that adds a widget that allows you to edit the content with a wysiwyg editor. I want to use the default wordpress editor by calling wp_editor(). I've seen ...
3
votes
2
answers
24k
views
Create Image Uploader for Widget
I found this post//
Use Media upload in custom widget on wordpress 3.5
I'm not experienced in any of this so I pretty much just copied the code he provided into my own functions.php file. I uploaded ...
3
votes
2
answers
503
views
Add New Footer Widget Area with Limited Options?
I'm trying to add a new footer widget area to my theme. I was able to add the new footer widget area and it works correctly. But I would like to limit what can be done with the widget area by the end ...
3
votes
5
answers
3k
views
How do I create a widget that only allows a single instance?
How do I create a widget that only allows a single instance of a widget to be added through the Wordpress interface?
The default behaviour of widgets allows multiple instances to be added.
I am ...
2
votes
1
answer
4k
views
How to Make a Custom Dashboard Widget to Display Custom Notification from Admin?
I am looking for a way to achieve the following:
A group of users 'students'
They login to the site
Each student can see a 'Custom Dashboard Widget(s)'
Each widget will carry a personal message ...
2
votes
2
answers
2k
views
Hooking Into Widget Output Loop
When wordpress sidebar outputs any particular registered sidebar it loop through all widgets that assigned through it and outputs it (i guess). Is is possible to hook into the loop and add some ...
1
vote
2
answers
1k
views
Transform php code into a widget?
how can I create a widget out of a php code? It's just a disqus code that I would like to place in the sidebar. I could just paste the code in the widget section (my tag), but then I would not be ...
1
vote
1
answer
228
views
How to create a widget or plugin to add custom content to my website?
I've made a dropdown menu of multiple pages on one HTML page.
Right now the only place to change the content of each page is inside the HTML of the theme. But this content will be changed weekly, ...
0
votes
4
answers
1k
views
How Can A Widget With Only One Instance Be Defined?
How can a widget which of which only one instance can be used?
10
votes
7
answers
21k
views
Adding a div to wrap widget content after the widget title
I'm trying to add a div to a widget's content in my dynamic sidebar.
Here is the register code;
register_sidebar(array(
'name' => "Sidebar1",
'id' => 'home-sidebar-1',
'...
9
votes
4
answers
10k
views
How to enqueue script if widget is displayed on page?
I created a widget that uses a jquery plugin, and I used is_active_widget to enqueue the script, it's working fine but it's also including the script even on pages that doesn't show this widget.
so is ...
8
votes
2
answers
43k
views
Code for Recent Posts Widget
I want to make changes to code of the Recent Posts widget – could anyone please tell me where that code is located?
Thank you in advance!
8
votes
4
answers
8k
views
Get number of widgets in sidebar
How can I get the number of widgets that are active on a specific sidebar? Is there a core function for this?
I want to add a class to each widget on a sidebar based on how many of them are displayed....
8
votes
1
answer
208
views
Can a widget in the Customizer be “single-use” (i.e. disabled after 1 instance has been added)?
I’m on a nightly quest to build a custom single-use widget.
As soon as one instance of it has been added to a sidebar panel in the Customizer, its control on the Available Widgets panel should be ...
7
votes
1
answer
14k
views
Get a list of all Widgets registered in WordPress admin widgets-area
I'm trying to disable a couple standard widgets in my theme functions.php.
Therefore I wrote this little function, which works well:
function my_widget_ctrl() {
unregister_widget('...
6
votes
2
answers
16k
views
Adding iframe Content to Sidebar Widget
I'm trying to add an Amazon advertising widget in a WordPress sidebar widget (self-hosted WordPress, v3.1.3). The widget code is basically an iframe.
I've tried using the "Text" widget and pasting ...
5
votes
2
answers
3k
views
How To Determine If A Filter Is Called In A Sidebar/Widget Context?
So I have a plugin that appends or prepends an enhanced author biography to the content of a page/post/custom post type.
It does this by hooking to either the_content or the_excerpt and appending/...
4
votes
1
answer
4k
views
Loop through widgets in sidebar
I have a sidebar called footer, I know I can use dynamic_sidebar() but I need to be able to split that into individual widgets.
I have the following so far which gives me the widget name e.g. text-1, ...
4
votes
2
answers
4k
views
Getting post-thumbnails from another WP site
I have two WordPress installations, one at http://inversekarma.in and the other at http://inversekarma.in/photos. The latter is a photoblog, and its theme uses the standard WP post thumbnails (EDIT: ...
4
votes
2
answers
1k
views
Limit widget to a specific registered sidebar
I have a widget I want only allowed to be used with the single.php sidebar. When I referenced the codex for register sidebar there isn't a way to limit widgets in the array. I've researched with "...
4
votes
3
answers
13k
views
How to Remove All Widgets from Dashboard?
I'm looking for a complete blank Dashboard. No widgets at all and preferably one column.
There are snippets to remove the default WordPress widgets but haven't found anything about the ones added ...
3
votes
2
answers
2k
views
How to place random widgets in the Wordpress sidebar?
My pages have a sidebar with too many widgets, and it looks bad when the content is short and the sidebar is too long.
I want to randomize the widgets I'm showing in the sidebar. Meaning I will add ...
3
votes
3
answers
3k
views
Add class to before_widget for all widgets with a dropdown and a counter
Some predefined widgets offer the option to use a select element (dropdown) and/or a counter after each entry. How can I add the CSS classes widget-with-dropdown or widget-with-counters to these ...
3
votes
2
answers
5k
views
get_intermediate_image_sizes Get the Size Names but How Do I Get the Sizes?
I'm setting up a widget that allows to add an image to a sidebar / widget area.
Basically I have a dropdown that allows the user to select one of the available sizes inside the theme's functions.php ...
3
votes
3
answers
4k
views
How to determine the current widget's parent container (sidebar widget id)
I have several custom widgets that are installed as part of my theme. I'd like to execute conditional code inside each widget's admin panel (not the public side, I'm just interested in the admin panel ...
2
votes
2
answers
591
views
Different rss feeds in a single dashboard widget
I am using this snip of code to get rss feed on my dashboard as widget. It becomes problematic when it displays 5-6 different rss feeds which makes me run down deep.
How can I add 6 different feeds ...
2
votes
1
answer
2k
views
Custom shortcode in widget forced to top of widget
A custom shortcode i made is being forced to the top of the widget outside of the widget container. Any ideas why? This is my code...
function nktmediaplayer_func($atts) {
extract(shortcode_atts(...
2
votes
2
answers
2k
views
Add a banner to the Dashboard
Is there a way to add a banner to the WP dashboard? I don't mean in a custom widget or anything, just a simple image banner.
2
votes
1
answer
4k
views
is_active_sidebar() Always Returns False
I've never gotten is_active_sidebar() to work, no matter if there's widgets in the sidebar or not I always get false returned. Currently I'm creating a sidebar for each top level page:
http://...
2
votes
1
answer
214
views
WordPress widget / plugin....fields not appearing in my widget
Trying to create my first plugin. A simple one. It's doing mainly what I want to do except the widget itself in Appearance-->Widgets doesn't display my fields. Wondering if anyone could point me in ...
2
votes
1
answer
21k
views
How to execute SQL SELECT query and see the results?
I want to run a SELECT query on the Wordpress database and get the results on the screen.
Any widget which does it?
2
votes
2
answers
11k
views
Current theme broken - after server and domain migration
I'm migrating a Wordpress install and trying to get down the correct process for doing so.
I've tried using the method I thought would work, but it didn't.
My files and database are in place, but ...
2
votes
1
answer
1k
views
Adding inline styles from a widget
I'm working on a theme that has an optional widget to allow users to put some site elements where they want. One of those is a list of social media icons. These are font icons, so they can be styled ...
2
votes
4
answers
1k
views
Pages with 2 Columns
I've had a look at many of the available plugins but they all seem to be too difficult to use or do not provide enough flexibility.
Plugins I've already tried:
WP Post Columns
Magazine Columns
WP ...