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

learn more… | top users | synonyms (1)

27
votes
4answers
4k 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 ...
21
votes
2answers
6k 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 ...
5
votes
1answer
2k 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 ...
0
votes
2answers
289 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
1answer
1k 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 ...
17
votes
2answers
5k views

Between functions.php, 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 ...
10
votes
4answers
3k 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 ...
8
votes
3answers
3k 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 ...
9
votes
2answers
2k 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 ...
3
votes
2answers
303 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 ...
1
vote
2answers
419 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 ...
9
votes
3answers
7k 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 ...
15
votes
2answers
3k 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 ...
5
votes
3answers
3k views

Add class to before_widget from within a custom widget

I have a simple custom widget that asks for its width (that is used later in the front end). The width field is a select dropdown, so a user have predefined options. I will have many instances of my ...
4
votes
1answer
618 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 ...
3
votes
2answers
2k 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: ...
1
vote
2answers
760 views

How can I add an incremental class identifier to my sidebar widgets?

My sidebar widget code in functions.php looks like this... if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Home Sidebar', 'id' => 'home-sidebar-widget', ...
1
vote
2answers
51 views

Should use widgets in this case?

We develop a new WordPress site with a new theme developed exclusively for this site. Some widgets of the same type (such as two "Bookmarks" widgets) should be styled differently (that is have ...
0
votes
1answer
871 views

Enabling Default Widgets in a Custom Theme

In custom theme development, how does one enable default built-in widgets? Note I mean default built-in widgets, not custom ones. I tried the following example for a WP 3.12 blog by placing it in my ...
3
votes
3answers
2k 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 ...
1
vote
2answers
343 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.
1
vote
1answer
1k views

Image picker widget

I want to create a custom widget so the user can select 2 images from the media library via a dropdown box and display them in a sidebar. So I need the widget to display 2 drop downs, which each show ...
5
votes
1answer
220 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 ...
4
votes
1answer
5k 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 ...
3
votes
2answers
1k 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?
2
votes
3answers
1k 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 ...
3
votes
1answer
1k 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 = ...
2
votes
3answers
1k 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 ...
1
vote
1answer
53 views

Display single widget

I've created a simple one-off widget to let the admin change some copy on the home page, but the widget isn't showing its contents. On the home page, I have this code: <?php ...
1
vote
1answer
66 views

Call sidebar from a template

I need to call a sidebar into my header. I've switched to the new twenty twelve theme and created my own child theme. With this new theme I decided to keep things organised and together, so I put my ...
1
vote
1answer
113 views

Big side banners

I would like to have a big header side advertisements like this: What is the best way to achieve that?
1
vote
2answers
473 views

Install widget on plugin activation

Anyone know any resources to help me install my widget when my plugin is activated?
1
vote
4answers
762 views

How Can A Widget With Only One Instance Be Defined?

How can a widget which of which only one instance can be used?
0
votes
1answer
535 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: ...
0
votes
2answers
511 views

FTP Widget Location

I am trying to recover some code I had several months ago (I have backups of everything). It was part of a text widget in my WordPress sidebar. If I have the full backup, where can I find that code? ...
0
votes
2answers
237 views

Button in SideBarOther widget not showing up on all pages

An item in SideBarOther shows up on the main article listing page, but when I select an article (same page layout, the article replaces the listing), the item isn't there. There are two items in ...
7
votes
3answers
2k views

Limit widget to certain sidebar?

I have multiple "sidebars", but not all of them are the same size. Not all widgets fit in all sidebars (for example, I have a "footer sidebar" where the client can place custom widgets, but they are ...
5
votes
1answer
8k views

Translate widget titles using qTranslate plugin

I'm actually using the qTranslate plugin to translate my website. It works really well with everything except one thing. the titles of my sidebar widgets. Actually, to translate some words we need to ...
5
votes
4answers
4k views

Using widget options 'outside' the widget

I want to save some parameters in the widget options which are then passed into another page. The widget is a form which calls a webservice. The options I want to pass are the authentication for the ...
2
votes
6answers
6k views

Including Custom Post Types in “Recent Posts” Widget

I'm able to easily include my custom post types into my main loop by making small adjustments with query_posts(), but I'm not sure how I would go about including custom post types in the "Recent ...
5
votes
4answers
2k views

dynamically add scripts to WP_Widget widget() method

I have a wordpress widget that has the standard outline like: class my_widget extends WP_Widget{ function my_widget(){ //do setup stuff } function form(){ //do form stuff } function ...
3
votes
3answers
5k 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?
3
votes
1answer
2k views

Add a custom walkter to a menu created in a widget

I know how to add a Walker to a custom menu created by the theme (menu named primary in this example), but how can I target a menu thats created in a widget with the default wordpress custom menu ...
2
votes
2answers
1k views

How to create a widget that has a submit form in the front end

How to create a widget that has a submit form in the front end? The reason for this is I'm teaching myself plugin development and I'm struggling on how to display a form on the front end after adding ...
2
votes
1answer
945 views

Enabling Widgets By Default in Custom Theme Development

In WP theme building, if a sidebar is not active, can I turn it on? Also, if the sidebar is active, and doesn't contain any widgets, can I add some? I'm a theme and plugin developer, but this is ...
1
vote
1answer
810 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 ...
1
vote
2answers
1k views

Including a custom post type in the Archives widget

I have a custom post type called "videos" that I want to include in the Archives widget (stock widget in the TwentyTwelve theme). It DOES already appear on the archives page, but just not in the ...
1
vote
2answers
1k views

WordPress “include TEMPLATEPATH” or?

I built something like this: Index Container Widgets Area and I created a widget for that - Categories Widget - Index Container .php with this in: <?php include (TEMPLATEPATH . ...
1
vote
3answers
302 views

Widget “Save” resetting jQuery hidden fields

I have a widget plugin that I've created, that lists about 10 fieldsets. jQuery runs at the beginning and hides and fieldsets that have no values. There are also buttons that allow to "Add" and ...
6
votes
3answers
1k views

How Do I Add Custom CSS To Only Certain Widgets

I have a standard dynamic sidebar using register_sidebar and dynamic_sidebar and I need the last widget in the sidebar (which will not have a set number of widgets) to have a distinct class ...