admin管理员组文章数量:1122832
Is there a way I can call a link so when clicked it publishes the post via the ID I provide? I have get_delete_post_link( $postID )
set fine, and would like to do the same to make a draft go to published, or if you can't publish post, make it pending. I also have this code running in my functions.php file so may be also a way to call this if a link is clicked.
Is there a way I can call a link so when clicked it publishes the post via the ID I provide? I have get_delete_post_link( $postID )
set fine, and would like to do the same to make a draft go to published, or if you can't publish post, make it pending. I also have this code running in my functions.php file so may be also a way to call this if a link is clicked.
1 Answer
Reset to default 0I used URL parameters and created a specific function called at init:
add_action( 'init', 'publish_post_status' );
function publish_post_status($post_id){
if (isset($_GET['publish']) && current_user_can('publish_posts')) {
if ($_GET['publish'] == "true") {
$current_post = get_post( $_GET['post_id'], 'ARRAY_A' );
$current_post['post_status'] = 'publish';
wp_update_post($current_post);
}
}
if (isset($_GET['queue'])) {
if ($_GET['queue'] == "true") {
$current_post = get_post( $_GET['post_id'], 'ARRAY_A' );
$current_post['post_status'] = 'pending';
wp_update_post($current_post);
}
}
}
本文标签: Get publish post link
版权声明:本文标题:Get publish post link? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736286384a1927659.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论