马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在给wordpress添加内容时,偶然会碰到文章复制的功能,但是wordpress又没有这个功能。把下面一段代码添加到functions.php文件中,就可以实现这个功能。
- /*
- * Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
- */
- function rd_duplicate_post_as_draft(){
- global $wpdb;
- if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
- wp_die('No post to duplicate has been supplied!');
- }
- /*
- * Nonce verification
- */
- if ( !isset( $_GET['duplicate_nonce'] ) || !wp_verify_nonce( $_GET['duplicate_nonce'], basename( __FILE__ ) ) )
- return;
- /*
- * get the original post id
- */
- $post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
- /*
- * and all the original post data then
- */
- $post = get_post( $post_id );
- /*
- * if you don't want current user to be the new post author,
- * then change next couple of lines to this: $new_post_author = $post
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
|