Can we have private drafts?

I would probably create a custom field / check box for this for a draft stage. Then hook into post status transition (or around) and when post is published force it to only private, even if normal publish was pressed. From personal experience custom post statuses are a wreck. They seem like a good idea, … Read more

Error trying to publish immediately. Post status = future (Missed schedule error)

So the issue in this case was that PHP wasn’t displaying correct UTC Time. Thanks to @TomJNowell for pointing me in the right way. It seems to be a bug/error in some Plesk installation: https://talk.plesk.com/threads/utc-time-issue-plesk-php-7-3-7-4-on-centos7.356169/ To solve the issue we have replaced the UTC file usr/share/zoneinfo/UTC with another copy from another server. After that, UTC … Read more

Disable “preview changes” button

Please replace $post_type with your post_type in question, e.g. post, page, cpt_slug,… The function echoing the meta box with the preview button is called post_submit_meta_box. The condition to show the button is set with the function is_post_type_viewable. Following that: If the {$post_type}s flags publicly_queryable or _builtin and public are set to true the preview button … Read more

How can I create custom button in post.php

Use media_buttons action for it. Check below code. add_action(‘media_buttons’, ‘add_my_media_button’); function add_my_media_button(){ echo ‘<a href=”‘.get_site_url().’/wp-admin/customize.php” class=”button button-default”>Customize</a>’; } Hope this will helps you. Thanks!

How to run a function when post is edited or updated using publish post action?

With the post_updated hook you can trigger an action when the post is updated. He passes 3 parameters: $post_ID (the post ID), $post_after(the post object after the edit), $post_before (the post object before the edit) Here’s an example: <?php function check_values($post_ID, $post_after, $post_before){ echo ‘Post ID:’; var_dump($post_ID); echo ‘Post Object AFTER update:’; var_dump($post_after); echo ‘Post … Read more

Notification to Admin or Author upon new post [duplicate]

You need to write your hook for transition_post_status action: function authorNotification( $new_status, $old_status, $post ) { if ( $new_status == ‘publish’ && $old_status != ‘publish’ ) { $author = get_userdata($post->post_author); $message = ” Hi “.$author->display_name.”, New post, “.$post->post_title.” has just been published at “.get_permalink( $post->ID ).”. “; wp_mail($author->user_email, “New Post Published”, $message); } } add_action(‘transition_post_status’, … Read more

Can I set a timer for pages to be published?

No script of function necessary. It’s actually built into WordPress. Simply go to your page to edit and on the right hand side you should see a widget labeled Publish. On the third line down, you will see an Edit button and you can set the date and time on when you want the page … Read more

How can I automatically set a post slug based on the post title during post publish?

As long as haven’t touched the slug WordPress will generate a new one after you entered a title. Update To change other peoples slugs use a filter (not tested!): add_filter( ‘wp_insert_post_data’, ‘prevent_numeric_slugs’, 10, 1 ); function prevent_numeric_slugs( $post_data ) { if ( ! isset ( $post_data[‘post_title’] ) or ! is_numeric( $post_data[‘post_name’] ) ) { // … Read more