URL重复问题Wordpress

时间:2016-05-20 02:12:51

标签: wordpress url

我在下载链接中遇到问题,网址重复。像这样http://localhost/test/files/http://localhost/test/files/2016/05/testonly.docx

与直播网站相同:http://www.homecredit.ph/wp-content/uploads/home1/homecre1/public_html/files/News-26.jpg,网址搞砸了

如何解决这个问题?我没有在.htaccess

中添加任何内容

htaccess的:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test/index.php [L]
</IfModule>

# END WordPress

以下是下载链接的代码:

的functions.php

function upload_user_file($file = array()){
    require_once(ABSPATH . 'wp-admin/includes/admin.php');
      $file_return = wp_handle_upload($file, array('test_form' => false));
      if(isset($file_return['error']) || isset($file_return['upload_error_handler'])){
          return false;
      } else {
          $filename = $file_return['file'];
          $attachment = array(
              'post_mime_type' => $file_return['type'],
              'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
              'post_content' => '',
              'post_status' => 'inherit',
              'guid' => $file_return['url']
          );

          $attachment_id = wp_insert_attachment($attachment, $file_return['url']);

          require_once(ABSPATH . 'wp-admin/includes/file.php');
          $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
          wp_update_attachment_metadata($attachment_id, $attachment_data);

          if(0 < intval($attachment_id)){
            return $attachment_id;
          }
      }
      return false;
}

自定义页面模板

echo '<td id="resumeFile'.$optionId.'"><a href=' . wp_upload_dir($record_s->attachment_resume_id) . '>Download Resume</a></td>';

0 个答案:

没有答案