Any way to change post/page status when editing page?

When editing a page, click on the cog wheel in the upper right corner to ensure the sidebar displays. There should be two tabs: Document and Block. Make sure Document is selected. There is an accordion item called Status & visibility, among Permalink, Discussion, and Page Attributes. If you click on Status & visibility to … Read more

How can I specify the post status of an untrashed post?

I think for your purpose wp_untrash_post_status filter will be enough. Will work with single and multiple posts restore. Filters the status that a post gets assigned when it is restored from the trash (untrashed). add_filter( ‘wp_untrash_post_status’, ‘change_untrash_post_status’); function change_untrash_post_status($status){ return ‘pending’; } P.S. apply_filtershook is used to call callback functions created by us, like a … Read more

retrieve post details in loop

First, change those = to === as mentioned by @sally-cj in the comment. On top of that, you’re saving the status as a variable called $stat and are then checking it as $status. So you might want to change $stat = get_post_status($job->ID); into $status = get_post_status($job->ID);. Or better: the $job is already populated with a … Read more

Alternative to new_to_publish Hook for Custom Statuses

new_to_holding doesn’t exist as a post status transition – you need to use the generic transition_post_status action. Something like (untested): add_action(‘transition_post_status’,’my_holding_function’, 10, 3); function my_holding_function( $new_status, $old_status, $post ) { if ( ‘holding’ == $new_status ) { // do stuff } }

Auto-change Post Status on First Page Load

If you want the default post status to be in-progress when contributors click on “New Post”, then you can try the following: /** * Set default post status as ‘in-progress’ for contributors * * @link https://wordpress.stackexchange.com/a/143128/26350 * * @param array $data * @return array $data */ function wpse_143100_wp_insert_post_data( $data ) { $current_user = wp_get_current_user(); if( … Read more

Programmatically change post visibility on save_post action return a 500

There is some information about this problem in the Action Reference for save post: If you are calling a function such as wp_update_post that includes the save_post hook, your hooked function will create an infinite loop. To avoid this, unhook your function before calling the function you need, then re-hook it afterward. So something like … Read more

Ajax function on #publish only saves as draft – how to make it publish?

Perhaps this solution will work: var flag_ok = false; $(‘#publish’).on(‘click’, function (e) { if ( ! flag_ok ) { e.preventDefault(); var url = shiftajax.ajaxurl; var shift = $(‘#post_ID’).val(); var data = { ‘action’: ‘wpaesm_check_for_schedule_conflicts_before_publish’, ‘shift’: shift, }; $.post(url, data, function (response) { if( response.action == ‘go’ ) { // there aren’t any scheduling conflicts, so … Read more

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