WordPress Permalink 404

时间:2015-12-26 作者:Sam Loyer

从版本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;  }
                        }
                    }
                }

1 个回复
最合适的回答,由SO网友:Milo 整理而成

将表单字段更改为具有更多唯一名称,特别是,title. This is an issue which was introduced when title was made a public query var in 4.4. 这被视为一个bug,最终会得到修复,但使用唯一的字符串预先设置任何变量以防止这些问题总是更安全的。

相关推荐

Wordpress Permalinks problem

Wordpress版本4.8(我不想使用4.9.1,因为模板页面属性有问题)我有个大问题。我读过很多解决方案,但对我来说并不适用。我正在创建一个自定义wordpress项目,一开始我的永久链接有问题。如果我使用“Plain”,这很好,但如果更改为例如“Date and time or something”,则会出现以下错误:我试着改变。htaccess,但看起来不错,这是我的。htaccess# BEGIN WordPress <IfModule mod_rewrite.c>