Categories lose hierarchy order once assigned to post

You could try out Scribu’s plugin, i believe this addresses the very problem you’re describing which has been reported on Trac a handful of times(but closed/deleted). Category Checklist Tree by scribu http://wordpress.org/extend/plugins/category-checklist-tree/ Related tickets: http://core.trac.wordpress.org/ticket/14723 http://core.trac.wordpress.org/ticket/10982 Hope that helps.. 🙂

Get all posts by post_author

The shortest possible answer would be to correct ‘post_author’ to ‘author’, since that is the key WP is looking for. If a key is incorrect or misspelled it will be ignored, as was the case with ‘post_author’.

How do I pass arguments to dashboard widget callback functions?

The args are stored in the 2nd variable passed to your callback function. add_action( ‘wp_dashboard_setup’, ‘sample_widget_setup’ ); function sample_widget_setup() { wp_add_dashboard_widget( ‘sample_dashboard_widget’, ‘Sample Widget’, ‘sample_dashboard_widget_callback’, null, ‘sample_string’ ); } function sample_dashboard_widget_callback( $var, $args ) { var_dump( $args ); } Output from above: array ‘id’ => string ‘sample_dashboard_widget’ (length=23) ‘title’ => string ‘Sample Widget’ (length=13) ‘callback’ … Read more

How to add a description to Widgets?

Here’s what you looking for: class WP_Widget_Sitemap extends WP_Widget { function WP_Widget_Sitemap() { $widget_ops = array( ‘classname’ => ‘widget_sitemap’, ‘description’ => __( “This is the description” ) ); $this->WP_Widget( ‘sitemap’, __(‘Site Map’), $widget_ops); } function widget() { … } function form() { … } function update() { … } … See: http://codex.wordpress.org/Widgets_API#Developing_Widgets

How to unregister a widget from a child theme

Assuming the Parent Theme’s Widget is registered at the widgets_init hook, all you need to do is wrap your unregister_widget() call inside of a function, hook that function into widgets_init, and give your hook a higher priority number than the Parent Theme’s widgets_init-hooked function. Assuming the Parent Theme hooks into widgets_init without giving a priority … Read more

What is the most efficient method for loading widgets in functions.php

Both are acceptable but not recommended. Use locate_template() instead because a child theme can overwrite the loaded file then. Example: $found = locate_template( ‘functions/my-custom-widget.php’, TRUE, TRUE ); The first TRUE tells WordPress not only to search for the file but to load it actually. The second makes it a require_once call. The function return the … Read more

Adding WordPress colorpicker in widget settings

The following worked for me. I using class attribute instead of ID to match multiple color pickers. <script type=”text/javascript”> jQuery(document).ready(function($) { jQuery(‘.color-picker’).on(‘focus’, function(){ var parent = jQuery(this).parent(); jQuery(this).wpColorPicker() parent.find(‘.wp-color-result’).click(); }); }); </script> My Widget form is set up like : <p> <label for=”<?php echo $this->get_field_id( ‘font_color’ ); ?>” style=”display:block;”><?php _e( ‘Font Color:’ ); ?></label> <input … Read more

Displaying Widgets

the_widget() is used to display a specific widget outside of a sidebar. To be honest, this function serves no valuable purpose as you need to hard code the widget $instance parameters, this means that you will need to manually change the code every time you need to change something. So much for dynamica. It would … Read more