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

Is there a way to know if a post has been published through XML-RPC?

You could use a custom field for a post which is saved via XMLRPC by using the action hook xmlrpc_publish_post. wpse_from_xmlrpc() could than check this custom field. <?php add_action( ‘xmlrpc_publish_post’, ‘add_xmlrpc_postmeta’ ); function add_xmlrpc_postmeta( $post_id ){ update_post_meta( $post_id, ‘send-by-xmlrpc’, 1 ); } function wpse_from_xmlrpc( $post_id ){ $xmlrpc = get_post_meta( $post_id, ‘send-by-xmlrpc’, true ); if( $xmlrpc … Read more

Does WordPress remove draft status automatically?

Just by itself WordPress will not change the post status. However, if you have a plugin like Draft Scheduler installed, drafts will be published automatically, possibly with some interval. So, you should check your plugins on this type of activity. Another possibility would be that a backup of the database has been installed after a … Read more

How can I display a specific user’s first published post?

The following query retrieves the oldest post of a specified user/author: $user_id = 42; // or whatever it is $args = array( ‘posts_per_page’ => 1, ‘post_status’ => ‘publish’, ‘author’ => $user_id, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ); $first_post = new WP_Query($args); if ($first_post->have_posts()) { $first_post->the_post(); // Now you can use `the_title();` etc. wp_reset_postdata(); } … Read more

Show recent published posts

The arguments you are using are wrong. They should be: $args = array( ‘numberposts’ => ’10’, ‘post_type’ => ‘post’, ‘post_status’ =>’publish’, ‘tax_query’ => array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array( 10, 11, 57 ), ‘operator’ => ‘NOT IN’, ) ); Or shorter: $args = array( ‘numberposts’ => ’10’, ‘post_type’ => ‘post’, ‘post_status’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)