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

Query All users that has post

add this in your arguments ‘query_id’ => ‘authors_with_posts’, $user_args = array( ‘role’ => ‘frontend_vendor’, ‘orderby’ => ‘display_name’, ‘query_id’ => ‘authors_with_posts’, ‘order’ => ‘ASC’, ‘number’ => $no, ‘offset’ => $offset );

Code Blocks with WYSIWYG in blog post

There are several ways to deal with this problem. You could have a look for some syntax highlighter plugin, those will also bring you coloured text with highlighted keywords etc. pp. This is probably nice, if you use code quite often. I use SyntaxHighlighter Evolved. If you want to do this by hand, <code> is … Read more