Widget modifications in a child theme

Widget are not part of hierarchical parent/child theme relation, so you would need to follow more generic development process: Optionally disable widget registration in parent theme (if possible to do cleanly – with hooks or otherwise). Extend (as in widget’s PHP class) or fork (copy and modify the code) widget in child theme. Register your … Read more

WP_enqueue_script() loads them always in wp_footer()?

All of these scripts are already registered to print in the footer. See wp-includes/script-loader.php for details. When you try to register the scripts again WordPress doesn’t change that. The workaround would be to register a new script for wp_head with those scripts as dependencies (the third parameter of wp_enqueue_script()). Do not register the scripts in … Read more

Hide widget if user is logged in without plugin

If you’re comfortable changing the code where the widget is outputted you could use the is_user_logged_in() function. Something like this: <div id=”widget_area”> <?php if ( is_user_logged_in() ) { // show nothing } else { dynamic_sidebar(‘widget_name’); } ?> </div> The downside being that this is now hard coded and you might have to add this function … Read more

Add individual tag to widget title in sidebar

dynamic_sidebar_params is the filter that lets you modify those parameters on a per-widget basis. It fires for every sidebar though, so you’ll need to use both add_action & remove_action call. Try var_dump once before writing the code to get an idea of what you have to do ADDED AN EXAMPLE ON REQUEST This example adds … Read more

Calling widget via function in themes files (hard code)

Using the_widget() is the correct way to “hard code” an arbitrary Widget in a template file: <?php the_widget( ‘foobar_widget’, $instance, $args ); ?> Since the_widget() simply returns if ‘foobar_widget’ is not a registered Widget, it is functionally equivalent to using an if ( function_exists( $function ) ) conditional. You could look in core to see … Read more

Creating a custom menu/widget area

I’m going to assume you’re using Twenty Eleven theme, or another theme that supports child themes. If you’re using a custom theme, then you can just edit the existing Functions.php and add your additional functionality there, and then edit the existing Style.css. However, if your situation is different, please post back, and I’ll update to … Read more

Add description to custom text widget and display the 5 recent post titles

You are not passing your description correctly. Really, you aren’t passing it at all. public function __construct() { parent::WP_Widget(false, $name=”Kevins Textbox”); array(‘description’ => __(‘A text widget created by Kevin Ullyott for practice in creating widgets’) ); } That ‘description’ line is creating an array but you aren’t doing anything with it. It is just floating … Read more

jQuery UI inside widget on admin page

Ok, so, for some reason I can’t comprehend, the answer is that the div element containing the tabs should have a class and not an id for jQuery UI to work properly, as such: <div class=”mytabs”> and jQuery(document).ready(function($) { $(“.mytabs”).tabs(); }); Just for the record, the way I enqued the scripts is: add_action( ‘admin_enqueue_scripts’, ‘load_my_admin_js’ … Read more