admin管理员组文章数量:1321074
When the user clicks on the preview I want to change the status of the post to "published" if not published and then reset my cache in my landing. Then after that, I want to revert the post status to the same stage. The last part of reverting to the same stage isn't working here is the code
add_filter( 'preview_post_link', function ( $link, \WP_Post $post )
{
$slug = $post->post_name;
$status_old = get_post_status($post->ID);
if($status_old != "publish"){
// return "/".$status_old;
$post = array('ID'=>$post->ID, 'post_status' => "publish" );
wp_update_post($post, true);
$response = wp_remote_request(";);
$post = array('ID'=>$post->ID, 'post_status' => $status_old );
// $post = array('ID'=>$post->ID, 'post_status' => "draft" );
wp_update_post($post, true);
} else {
$response = wp_remote_request(";);
}
return "mywebsite/".$slug;
}, 10, 2 );
本文标签: poststhe wppostupdate isn39t working all the time
版权声明:本文标题:posts - the wp_post_update isn't working all the time 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742091601a2420301.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论