Articles of widget text

WordPress Widget Not Saving Instance

I have very simple wordpress widget, that has 3 input field. Whenever i submit data, it does not save to database. I have added and deleted the plugin , deactivated and reactivated multiple times, but no luck. Below is my code :- class price_package extends WP_Widget { function __construct() { parent::__construct( ‘price_package’, ‘Price Package’, array( […]

Shortcode inside text widget do not call enqueue style

I did a plugin who call enqueue style inside a shortcode. But when i add my shortcode in a text widget the enqueue style are not included en the page. wp_enqueue_style(‘css-rfnb’, RFNB_PLUGIN_DIR_URL . ‘css/rfnb.css’);

How to add custom tinymce plugin to new text widget

So I have a custom TinyMCE plugin, which adds a button to the editor. I’m using the mce_external_plugins and mce_buttons filter to add my TinyMCE plugin. After WP 4.8 introduced the simple TinyMCE for the new text widget i would like to include my button i that editor as well. For some reason i can’t […]

Passing user enetered value in widget: number of words, for example

<a href=”<?php the_permalink(); ?>”> <?php the_title(); ?></a> The above is the code snippet from one of the widgets of my theme. Now in the widget arrangement, this is the situation → $instance[‘number_of_words’] = absint( $new_instance[‘number_of_words’] ); the above setting is to handle how many numbers of words do we wish to show in the title? […]

Can't Write Custom Widget Code In One ECHO

I am creating a WordPress custom widget and I created the below one that is working fine when I add it in function.php. <?php /* ————————————————————————- * * Most Commented Post Widget /* ————————————————————————- */ class show_popular_commented extends WP_Widget { function show_popular_commented() { $widget_ops = array(‘classname’ => ‘show_popular_commented’, ‘description’ => __(‘Show your popular commented posts.’)); […]

Different “Text Widgets” in Sidebar on Many Different Pages?

Hi there I have a few questions on adding different sidebar texts to sidebars per page. On one part of my site, I have pages dedicated to individual animals. I have figured out how to change the layout to include a left sidebar to these pages (registered the sidebar, called the sidebar). The intended use […]

Hook called before text widget save

I want to know which hook/action is called just before the Text Widget content and title is stored in the database. I googled alot but could not able to get the hook name. What I want is whenever a text widget save button is trigger (in admin panel) I want to apply my custom content […]

How to change text widget title h2 to h1

I created text widget and wordpress created some default styles it uses h2 tag and class “widgettitle”. How can i change tag to h1 and remove class from it. This is my function.php file function home_consultation_init() { register_sidebar(array( “name” => “Home Consulatation”, “id” => “home_consult”, “before_widget” => “”, “after_widget” => “”, “before-title” => “”, “after-title” […]

How to make widget title accept php?

I am trying to make widgets accept php, but without resorting to plugins. So far I have enabled php for the widget_text but cant make it work for widget_title. I am using the following code in functions.php: add_filter(‘widget_text’,’execute_php’,100); function execute_php($html){ if(strpos($html,”<“.”?php”)!==false){ ob_start(); eval(“?”.”>”.$html); $html=ob_get_contents(); ob_end_clean(); } return $html; } What would I have to do […]

Widget not displaying in WMPU sites

I’m modifying a theme for a WPMU install, and I’ve hit a wall. In order to display a text widget in a specified area, I’m using: $args = array( ‘before_widget’ => ‘<ul class=”widget-container”><li class=”widget”>’, ‘after_widget’ => ‘</li></ul>’, ‘before_title’ => ‘<h3 class=”widgettitle”>’, ‘after_title’ => ‘</h3>’ ); the_widget(‘WP_Widget_Text’, array(‘text’ => “[si-contact-form form=’1′]”), $args); The shortcode “[si-contact-form form=’1′]” […]