Can I add a widget to the of my site?

I took a closer look at the answer Mayeenul suggested, and with a combination of that and the top answer I got it to work. Seems like a custom plugin is the way to go, and much easier than I expected to implement. First I created a folder at inside wp-content/plugins/sv-custom-head (using my initials to … Read more

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

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