{"id":5731,"date":"2020-02-27T11:08:09","date_gmt":"2020-02-27T03:08:09","guid":{"rendered":"https:\/\/blog.naibabiji.com\/?p=5731"},"modified":"2020-02-27T11:08:09","modified_gmt":"2020-02-27T03:08:09","slug":"custom-upload-dir","status":"publish","type":"post","link":"https:\/\/blog.naibabiji.com\/tutorial\/custom-upload-dir.html","title":{"rendered":"\u81ea\u5df1\u642d\u5efa\u7684WordPress\u7f51\u7ad9\u600e\u4e48\u8bbe\u7f6e\u56fe\u7247\u4e0a\u4f20\u6587\u4ef6\u5939"},"content":{"rendered":"<p>\u9ed8\u8ba4\u5b89\u88c5\u5b8cWordPress\u7f51\u7ad9\u540e\uff0c\u4e0a\u4f20\u56fe\u7247\u6587\u4ef6\u5939\u662f\u6309\u7167\u5e74\/\u6708\u7684\u683c\u5f0f\u5b58\u653e\u5728\u670d\u52a1\u5668\u4e0a\u9762\u7684\u3002\u4f46\u662f\u8fd9\u6837\u8bbe\u7f6e\u5982\u679c\u67d0\u4e00\u4e2a\u6708\u4e0a\u4f20\u7684\u56fe\u7247\u6bd4\u8f83\u591a\uff0c\u7136\u540e\u52a0\u4e0a\u81ea\u52a8\u751f\u6210\u7684\u7f29\u7565\u56fe\uff0c\u90a3\u4e48\u6587\u4ef6\u5939\u91cc\u9762\u5c31\u4f1a\u5b58\u5728\u4e0a\u4e07\u5f20\u7684\u56fe\uff0c\u5f71\u54cd\u670d\u52a1\u5668\u6548\u7387\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u81ea\u5b9a\u4e49WordPress\u7684\u4e0a\u4f20\u8def\u5f84\u3002<\/p>\n<h2>\u81ea\u5b9a\u4e49WordPress\u4e0a\u4f20\u6587\u4ef6\u5939\u65b9\u6cd5\u4e00<\/h2>\n<p>\u6211\u4eec\u53ef\u4ee5\u5b89\u88c5Custom Upload Dir\u8fd9\u4e2a\u63d2\u4ef6\u6765\u5b9e\u73b0\u3002<\/p>\n<p>\u8fd9\u4e2a\u63d2\u4ef6\u53ef\u4ee5\u8ba9\u4f60\u81ea\u5b9a\u4e49\u4e0a\u4f20\u8def\u5f84\uff0c<span>\u60a8\u53ef\u4ee5\u6784\u5efa\u4ece\u50cf\u6587\u7ae0\u6807\u9898\uff0c\u5206\u7c7b\uff0c\u6587\u7ae0\u4f5c\u8005\uff0c\u53d1\u5e03\u65e5\u671f\u53d8\u91cf\u8def\u5f84<\/span><span>\u7b49\u7b49<\/span><span>\u3002<\/span><\/p>\n<p><a href=\"https:\/\/edgeone.naibabiji.com\/wp-content\/uploads\/2020\/02\/1020q167.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5732\" src=\"https:\/\/edgeone.naibabiji.com\/wp-content\/uploads\/2020\/02\/1020q167.png\" alt=\"WordPress\u81ea\u5b9a\u4e49\u4e0a\u4f20\u8def\u5f84\" width=\"471\" height=\"632\" \/><\/a><\/p>\n<p><a class=\"theme-demo\" href=\"https:\/\/wordpress.org\/plugins\/custom-upload-dir\" target=\"_blank\" rel=\"noopener noreferrer\">\u4e0b\u8f7d\u5730\u5740<\/a><\/p>\n<h2>\u81ea\u5b9a\u4e49WordPress\u4e0a\u4f20\u6587\u4ef6\u5939\u65b9\u6cd5\u4e8c<\/h2>\n<p>\u8fd9\u4e2a\u662f\u514d\u63d2\u4ef6\u7684\u4ee3\u7801\u5b9e\u73b0\u65b9\u6cd5\uff0c\u628a\u4e0b\u9762\u4ee3\u7801\u63d2\u5165\u5230\u4f60\u7f51\u7ad9\u4e3b\u9898\u7684\u51fd\u6570\u4ee3\u7801\u91cc\u9762\uff0c\u65e2\u53ef\u4ee5\u5b9e\u73b0\u4e0a\u4f20\u5230\u6307\u5b9a\u6587\u4ef6\u5939\u3002<\/p>\n<pre>add_filter('upload_dir', 'awesome_wallpaper_dir');\r\n\r\nfunction awesome_wallpaper_dir( $param ){\r\n    $mydir = '\/awesome';\r\n\r\n    $param['path'] = $param['path'] . $mydir;\r\n    $param['url'] = $param['url'] . $mydir;\r\n\r\n    return $param;\r\n}<\/pre>\n<p>\/awesome \u662f\u4f60\u8bbe\u7f6e\u7684\u8def\u5f84\u4f4d\u7f6e\u3002<\/p>\n<p>\u8be6\u7ec6\u5185\u5bb9\u8bf7\u53c2\u89c1\uff1ahttps:\/\/codex.wordpress.org\/Plugin_API\/Filter_Reference\/upload_dir<\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;5731&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;4&quot;,&quot;greet&quot;:&quot;\u7ed9\u672c\u6587\u6253\u5206 post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;\u81ea\u5df1\u642d\u5efa\u7684WordPress\u7f51\u7ad9\u600e\u4e48\u8bbe\u7f6e\u56fe\u7247\u4e0a\u4f20\u6587\u4ef6\u5939&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\">\u7ed9\u672c\u6587\u6253\u5206 post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u9ed8\u8ba4\u5b89\u88c5\u5b8cWordPress\u7f51\u7ad9\u540e\uff0c\u4e0a\u4f20\u56fe\u7247\u6587\u4ef6\u5939\u662f\u6309\u7167\u5e74\/\u6708\u7684\u683c\u5f0f\u5b58\u653e\u5728\u670d\u52a1\u5668\u4e0a\u9762\u7684\u3002\u4f46\u662f\u8fd9\u6837\u8bbe\u7f6e\u5982\u679c\u67d0\u4e00\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5733,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"\u81ea\u5df1\u642d\u5efa\u7684WordPress\u7f51\u7ad9\u600e\u4e48\u8bbe\u7f6e\u56fe\u7247\u4e0a\u4f20\u6587\u4ef6\u5939 - \u5976\u7238\u5efa\u7ad9\u7b14\u8bb0","description":"\u9ed8\u8ba4\u5b89\u88c5\u5b8cWordPress\u7f51\u7ad9\u540e\uff0c\u4e0a\u4f20\u56fe\u7247\u6587\u4ef6\u5939\u662f\u6309\u7167\u5e74\/\u6708\u7684\u683c\u5f0f\u5b58\u653e\u5728\u670d\u52a1\u5668\u4e0a\u9762\u7684\u3002\u4f46\u662f\u8fd9\u6837\u8bbe\u7f6e\u5982\u679c\u67d0\u4e00\u4e2a\u6708\u4e0a\u4f20\u7684\u56fe\u7247\u6bd4\u8f83\u591a\uff0c\u7136\u540e\u52a0\u4e0a\u81ea\u52a8\u751f\u6210\u7684\u7f29\u7565\u56fe\uff0c\u90a3\u4e48\u6587\u4ef6\u5939\u91cc\u9762\u5c31\u4f1a\u5b58\u5728\u4e0a\u4e07\u5f20\u7684\u56fe\uff0c\u5f71\u54cd\u670d\u52a1\u5668\u6548\u7387\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u81ea\u5b9a\u4e49WordPress\u7684\u4e0a\u4f20\u8def\u5f84\u3002 \u81ea\u5b9a\u4e49WordPress\u4e0a\u4f20\u6587\u4ef6\u5939\u65b9\u6cd5\u4e00 \u6211\u4eec\u53ef\u4ee5\u5b89\u88c5Custo"},"footnotes":""},"categories":[141],"tags":[],"class_list":["post-5731","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial"],"_links":{"self":[{"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/posts\/5731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/comments?post=5731"}],"version-history":[{"count":0,"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/posts\/5731\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/media\/5733"}],"wp:attachment":[{"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/media?parent=5731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/categories?post=5731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.naibabiji.com\/wp-json\/wp\/v2\/tags?post=5731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}