Custom Status of Custom Post type need to EXCLUDE from Taxonomy pages
Custom Status of Custom Post type need to EXCLUDE from Taxonomy pages
Custom Status of Custom Post type need to EXCLUDE from Taxonomy pages
date(‘M’) => ‘Aug’ and date(‘m’) => 08 add_action(‘wp’, function(){ $current_month = date(‘M’); if( $current_month == ‘Aug’ ) { wp_update_post( array( ‘ID’ => “product_id”, ‘post_status’ => ‘publish’ )); } else { wp_update_post( array( ‘ID’ => “product_id”, ‘post_status’ => ‘draft’ )); } });
Here is how I realized a simple media workflow. Security checking and sanitizing is up to everyone. Based on WordPress version: 4.9.8 Create Attachment Post | Handle Media if (!empty($_FILES) && isset($_POST[‘postid’])) { media_handle_upload(“attachments”, $_POST[‘postid’]); } Post status pending is not possible for attachments when using media_handle_upload. For this case a filter needs to be … Read more
wp_insert_post_data filters post data just before it is inserted into the database. Documentation add_filter(‘wp_insert_post_data’, ‘schedule_post_on_publish’, ’99’); function schedule_post_on_publish($data) { $post_type = “event”; // Replace event with exact slug of your custom post type if ( $data[‘post_type’] == $post_type AND $data[‘post_status’] == ‘publish’ ) { $data[‘post_status’] = ‘future’; } return $data; } This may help.
transition_post_status not working via Quick Edit
The $post you’re working with is a WP_Post Object and you must interact with it as so. $post->post_status=”draft”; It’s usually not a good practice to modify the $post object directly so it’s something you may want to avoid. A better way may be to simply pass an array of values to wp_update_post() function like so: … Read more
Several WordPress core features, such as checking for updates and publishing scheduled post, utilize WP-Cron. The problem is likely you had no visits to your site since the time the post is scheduled to. Scheduling errors could occur if you schedule a task for 2:00PM and no page loads occur until 5:00PM. Source: “What is … Read more
You can user if..else condition to combine both function into one hook. add_action( ‘transition_post_status’, ‘groupqueue_to_groupcpt_and_groupcpt_to_bannedcpt’, 10, 3); function groupqueue_to_groupcpt_and_groupcpt_to_bannedcpt($new_status, $old_status, $post){ //Move to Group Post Type if (‘publish’ === $new_status && ‘groupq’ === $post->post_type ) { wp_update_post(array( ‘ID’ => $post->ID, ‘post_type’ => ‘group’ ), true ); } else if ( ‘banned’ === $new_status && (‘groupq’ … Read more
Featured image overlay when changing post status
I think you need to handle post request first. You have to do this because gutenberg calls the hook twice. function transition_post_status_handler( $new_status, $old_status, $post ) { if ( defined( ‘REST_REQUEST’ ) && REST_REQUEST ) { send_mail_on_publish( $new_status, $old_status, $post ); set_transient( ‘post_status_updater_flag’, ‘done’, 10 ); } else { if ( false === get_transient( ‘post_status_updater_flag’ … Read more