【问题标题】:Wordpress and cut URL while uploading上传时的 Wordpress 和剪切 URL
【发布时间】:2017-03-03 17:15:09
【问题描述】:

我正在与wordpress + acf + rest acf 合作,我需要删除一些 URL。

而不是在我的 JSON 中显示完整的图像 URL:

"intro_img": {
            "url": "http:\/\/127.0.0.1\/app\/wp-content\/uploads\/2016\/10\/intro.png",
        }

我需要更多类似的东西:

"intro_img": {
                "url": "uploads/2016/10/intro.png",
            }

我可以做些什么来减少 URL 仅用于上传的文件?

感谢您的帮助

【问题讨论】:

  • 将 get_site_url()."/wp-content" 替换为 ''
  • 为什么不在 wp-content/uploads 上炸开你的路径,然后在处理数据之前剪掉它?

标签: php wordpress curl


【解决方案1】:

检查一下,

$data = array('intro_img'=>array('url'=>"http:/127.0.0.1/app/wp-content/uploads/2016/10/intro.png"));
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
echo $data;

【讨论】:

  • 感谢您的回答,看起来不错,但事实是我不知道该代码在哪里,在哪个文件中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-14
  • 1970-01-01
  • 1970-01-01
  • 2020-01-20
  • 2011-03-27
相关资源
最近更新 更多