Add custom class to a tags [closed]

As s_ha_dum said, Widgets are not meant to be used like this. If you want to change the behavior of all your h3 tags inside your posts, WordPress has already article with “post” or “type-post” classes so you should modify your css like this : .post h3 { *** } If you want your change … Read more

if is within sidebar [duplicate]

EDIT: Here I have registered 2 sidebars in functions.php with names sidebar1 and sidebar2. $sidebar_args = array( ‘name’ => __( ‘sidebar1’, ‘theme_text_domain’ ), ‘id’ => ‘sidebar-1’, ‘description’ => ”, ‘class’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ ); register_sidebar( $sidebar_args ); $sidebar_args_2 = array( … Read more

Use of apply_filter in plugin/widget class

I’m not sure if you are missing some code in the constructor where you write //code here : function __construct() { //code here } Try replacing it with: function __construct() { parent::__construct( ‘byad_countdown_widget’, // Base ID __(‘Byad Countdown’, ‘byad_countdown’), // Name array( ‘description’ => __( ‘The Byad Countdown Widget’, ‘byad_countdown’ ), ) // Args ); … Read more

how to use get_field_name in external ajax handler

Why you want to use ajax for showing some fields on form in widget? Can’t it be done using simple show hide using jquery. See below. Not tested , just to give insight. HTML <input type=”radio” id=”someradio” /> <div id=”somediv” style=”display:none;”> <input type=”text” name=”<?php $this->get_field_name(‘name’); ?>”> </div> Jquery <script type=”application/javascript”> jQuery(‘#someradio’).on(‘click’,function(){ jQuery(‘#somediv’).toggle(); }); </script>

Insert to wp_footer if widget is found in the sidebar

The constructor of widget is called when the widget is registered, so your add_action is called on (probably) every request. You can avoid that simply put the add_action inside widget() function, that is called only when the widget is printed so there is no need to check: just output what you want. Also, if you … Read more

Widget checkbox array empty on update function

I suspect this is mostly happening because down towards the bottom, you’ve got an input that’s not using $this->get_field_name() (the first of the two checkbox inputs). Try using $this->get_field_name() as you did in the “then” clause of that section of code and it should be OK. Not much else wrong that I can see.