Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Are wordpress widgets for the most part universal? WordPress


The title pretty much says it all.

As far as moving them from theme to theme, unless they are plugin specific?

I ask because I have a few themes and would like to integrate some widgets into one theme from the others.

Please try to explain in simplicity if you reply, as I am early in readying into the wordpress codex

Sorry, I am new to wordpress used to be all Vbulletin. :P

Answers (2)

2012-09-22

Plugarized answers:

WordPress Widgets are like a plugin, but designed to provide a simple way to arrange your sidebar content without having to change any code. Widgets can include the search bar, recent comments, recent posts, tags, for example.

Most plugins have widgets available and you can place these on sidebars.

Here is a video explaining what a wordpress widget is http://www.youtube.com/watch?v=5d9dAW1Dyz0


Plugarized comments:

Any widget available through plugins can be used on any WordPress installation, all you have to do is upload the plugin to the plugin's folder and then activate it through the plugin administration and if that plugin has a widget available you go to the widget panel and add it to a sidebar.

Some widgets are hardcoded into a theme and thats because it is using functions custom made for that theme only perhaps. with experience you can extract these and make your own plugin for your theme.

2012-09-22

Dbranes answers:

Yes, the widgets are for the most part universal, i.e. they are theme independent in general
(but some themes come with their own widgets)

Here is a good starting point:

https://codex.wordpress.org/WordPress_Widgets

http://en.support.wordpress.com/widgets/

To use the widgets in your theme, you need to "widgetize" it, see fx.

http://automattic.com/code/widgets/themes/

but most of the new themes today are widget ready.

You can also build your custom widgets:

http://wp.tutsplus.com/tutorials/creative-coding/building-custom-wordpress-widgets/

or install a plugin with a special widget you need.

Hope this helps.


nimo comments:

This is directed for both replys. Maybe I should have been clearer.

Your both saying for the most part I should be able to use most widgets on any theme?

If I were to run into problems what would be the likely cause of that?

Whats the process of transfering a widget from one theme to the next? (codex page link?)

Thanks!


Dbranes comments:


If a widget is defined within the theme, the code is most likely to be found in the file "functions.php" (in the current theme directory)

You could then search for code like:

register_widget("some widget name")


http://codex.wordpress.org/Function_Reference/register_widget


and WP_Widget class extensions:

class some_widget_name extends WP_Widget


http://codex.wordpress.org/Widgets_API


Dbranes comments:

if you have access to linux command line, you can just use grep, fx like:

grep "register_widget" -R .


within the /wp-content/themes/ directory.


Dbranes comments:

here is an example of a widget defined within a theme:

theme TwentyEleven:

/twentyeleven/functions.php: register_widget( 'Twenty_Eleven_Ephemera_Widget' );
/twentyeleven/inc/widgets.php:class Twenty_Eleven_Ephemera_Widget extends WP_Widget {