Dynamic dependent Dropdown lists for categories, sub-categories and posts

you may find your answer here and Here’s a demo of it. HTML code example <div class=”ccms_form_element cfdiv_custom” id=”style_container_div”> <label for=”brand”>Make:</label> <select size=”1″ id=”make” class=” validate[‘required’]” title=”” onChange=”updatepage();” type=”select” name=”style”> <option value=”-1″>–Choose a Make-</option> <option class=”Audio” value=”Audi”>Audi</option> <option class=”BMW” value=”BMW”>BMW</option> </select> <div class=”clear”></div><div id=”error-message-style”></div> <div id=”style-sub-1″ class=”BMW” style=”display: none;” name=”stylesub1″ onchange=”ChangeDropdowns(this.value)”> <label for=”brand”>Model:</label> <select name=”cat” … Read more

remove post and categories/tags count from right now dashboard widget

There is no filter in PHP, so we have to use JavaScript: add_action( ‘admin_footer-index.php’, ‘wpse_82132_hide_rows’ ); function wpse_82132_hide_rows() { $rows = array ( # ‘posts’, # ‘pages’, ‘cats’, // meoww! ‘tags’, # ‘comments’, # ‘b_approved’, # ‘b-waiting’, # ‘b-spam’, ); $find = ‘.’ . join( ‘,.’, $rows ); ?> <script> jQuery( function( $ ) { … Read more

Disable sticky option for specific categories

I ended up going with another approach. I check to see what the current user’s role is, then if the role is ‘author’, enqueued a CSS file to hide the sticky option’s checkbox. In the theme’s functions.php file: function hide_sticky_option($hook) { global $current_user; if(‘post.php’== $hook || ‘post-new.php’==$hook){ $role = array_shift($current_user->roles); //get role of current user … Read more

Query Posts With Over 1000 Views

This should work, but I didn’t have the time to test it. $query = new WP_Query( array( ‘meta_key’ => ‘_hit-counter’, ‘meta_value’ => ‘1000’, ‘meta_compare’ => ‘>=’, ‘orderby’ => ‘date’ ) );

Customizing Comments on Posts

Set per_page to 5 and page to 1 in wp_list_comments http://codex.wordpress.org/Function_Reference/wp_list_comments Then add your read more link just below your comments to reload the page with per_page and page not set. You can do this with AJAX for smoothness.

WordPress Automatic Filename Changer

The add_attachment action is called after the attachment has been named. If you only want to change the name of the attachment (and the slug), you don’t need to change the name of the file and can just replace the code inside rename_attachment with a call to wp_update_post. add_action(‘add_attachment’, ‘rename_attacment’); function rename_attacment($post_ID){ $new_attachment_name = array( … Read more

Set Default Category to Username

The default category is stored in the options table under option named default_category , so you can do something like this: add_action(‘admin_init’,’set_user_default_cat_wpa89057′); function set_user_default_cat_wpa89057(){ global $current_user; if ( isset($current_user) ) { update_option( ‘default_category’, $current_user->user_login); } }