Add filter-by-tag in the all posts admin console page

User ‘restrict_manage_posts’ filter to add another filter. Use the following code in functions.php function kc_add_taxonomy_filters() { global $typenow; // an array of all the taxonomyies you want to display. Use the taxonomy name or slug $my_taxonomies = array( ‘post_tag’ ); switch($typenow){ case ‘post’: foreach ($my_taxonomies as $tax_slug) { $tax_obj = get_taxonomy($tax_slug); $tax_name = $tax_obj->labels->name; $terms … Read more

Prevent post from being published if no category selected

You can do this easily with jQuery: /* Checks if cat is selected when publish button is clicked */ jQuery( ‘#submitdiv’ ).on( ‘click’, ‘#publish’, function( e ) { var $checked = jQuery( ‘#category-all li input:checked’ ); //Checks if cat is selected if( $checked.length <= 0 ) { alert( “Please Select atleast one category” ); return … Read more

generate unique slug while inserting post

You don’t have to think about it – WordPress will take care of this. Let’s take a look at wp_insert_post source code… On line 3203 you’ll find: if ( empty($post_name) ) { if ( !in_array( $post_status, array( ‘draft’, ‘pending’, ‘auto-draft’ ) ) ) { $post_name = sanitize_title($post_title); } else { $post_name=””; } } else { … Read more