从版本4.4开始,我就有Permalink的问题,从前端开始,当成员尝试插入帖子时,单击提交按钮时显示404,无法插入帖子时,仅显示404,当我在WordPress设置中从%postname%更改为普通工作时,工作正常。
<form id="submitForm" action="<?php the_permalink(); ?>" method="post" enctype="multipart/form-data">
$post_data = array(
\'post_author\' => $current_user->ID,
\'post_type\' => $dox_options[\'ad_set\'][\'type\'][\'base\'],
\'post_title\' => $_POST[\'title\'],
\'post_content\' => $_POST[\'description\'],
\'post_status\' => \'pending\',
\'comment_status\' => \'closed\',
\'ping_status\' => \'closed\'
);
/* insert post */
$ad_id = wp_insert_post( $post_data, $post_error );
if ($post_error == false) {
/* required files */
require_once(ABSPATH . "wp-admin" . \'/includes/image.php\');
require_once(ABSPATH . "wp-admin" . \'/includes/file.php\');
require_once(ABSPATH . "wp-admin" . \'/includes/media.php\');
$files = $_FILES[\'attachment\'];
if ($files) {
foreach ($files[\'name\'] as $key => $value) {
if ($files[\'name\'][$key]) {
$file = array(
\'name\' => $files[\'name\'][$key],
\'type\' => $files[\'type\'][$key],
\'tmp_name\' => $files[\'tmp_name\'][$key],
\'error\' => $files[\'error\'][$key],
\'size\' => $files[\'size\'][$key]
);
}
$_FILES = array("attachment" => $file);
foreach ($_FILES as $file => $array) {
$attach_id = media_handle_upload( $file, $ad_id, array(), array( \'test_form\' => false ) );
if ($attach_id < 0) { $post_error = true; }
}
}
}