Articles of widgets

How to Sync Menu, Widgets and other masters from Main Website to its Sub Site

I am using WordPress Multisite Network and i am having problems regarding masters to its subsite. I am not able to see the widgets or Menus which were created on Main website to its Sub-site. When i am going to check in the Database whole tables are different of every subsite. So is there any […]

display specific widget to a page

im trying to display a specific widget i need for the header current im using a code to display all widgets but my problem is that if I add additional widgets it will destroy my site. <?php dynamic_sidebar( ‘sidebar2’ ); ?> <?php else : ?> <!– This content shows up if there are no widgets […]

How to translate Widget Description in constructor?

I’m building a localized widget and the translation works everywhere but in the language string in the constructor. I have read that the whole plugin initialisation has to be bound to the init hook to avoid that problem, but i don’t know to do this because if i try to register the widget with init […]

Escape HTML on WP input

I am slightly stuck on creating a widget, it has an input (bit like the default text widget) but got an issue adding html into it. My code is: $instance[‘content’] = ( ! empty( $new_instance[‘content’] ) ) ? esc_html( $new_instance[‘content’] ) : ”; This works partially as it let me saves the HTML (an iframe) […]

Why isn't my custom widget outputting any content?

I’ve been following numerous tutorials and codex pages in order to make my own widget in WP 4.0. It seems as though I’m very near; I can output something from the widget, just not any of the fields. In banner.widget.php I have the following: class bannerWidget extends WP_Widget { public $id_base = ‘banner_widget’; public $name […]

How do I make the title of the following widget editable?

I have the following widget which displays basic info for a game: class Game_Info_Widget extends WP_Widget { /** * Register widget with WordPress. */ public function __construct() { parent::__construct( ‘game_info_widget’, // Base ID ‘Game – Info’, // Name array(‘description’ => __(‘Game – Info’, ‘text_domain’),) // Args ); } /** * Front-end display of widget. * […]

Static image for embedded YouTube video instead of blank player?

Thanks to this answer I have embedded a YouTube video in a Text Widget using However it displays as this blank player when the page is loaded: I’ve tried adding a &start=1 to get it to show the first frame of the video but that doesn’t have any effect. How can I get this embedded […]

Show different website layout if no sidebar added

I have a question about website layout with and without wp widges in sidebar. Here is the code i have for my registered sidebar. <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(products) ) : endif; ?> And this is the code i have in functions.php if (function_exists(‘register_sidebar’)) { $opts = array( ‘name’ => ‘Products’, ‘before_widget’ => ‘<div […]

modifying title (in dashboard) for different widget instances

When I insert multiple instances of widget in a particular sidebar, they all appear by default collapsed and with the same title. E.g.: In this case, the user can upload a different pic to each widget, and reorder them as they want. It’s not very user friendly having to click to open each one to […]

How to add css classes to widgets?

I need to add a class to the WordPress search widget. How would I go about doing so? I’m calling it from the admin side, as in dragging and dropping it into the sidebar at the widgets page of the admin section. I’m not calling it using get_search_form. I want to do so by using […]