{"id":2563,"date":"2025-06-11T03:59:46","date_gmt":"2025-06-10T19:59:46","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/2563.html"},"modified":"2025-06-11T03:59:46","modified_gmt":"2025-06-10T19:59:46","slug":"%e5%a6%82%e4%bd%95%e4%bb%8ewordpress-url%e4%b8%ad%e7%a7%bb%e9%99%a4%e6%97%a5%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/2563.html","title":{"rendered":"\u5982\u4f55\u4eceWordPress URL\u4e2d\u79fb\u9664\u65e5\u671f"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"Bug&#32534;&#35793;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">Bug&#32534;&#35793;&#29422;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312;WordPress&#20013;&#65292;&#20320;&#21487;&#20197;&#36890;&#36807;&#20462;&#25913;&#27169;&#26495;&#25991;&#20214;&#25110;&#20351;&#29992;&#25554;&#20214;&#26469;&#21435;&#38500;URL&#20013;&#30340;&#26085;&#26399;&#37096;&#20998;&#12290;&#20197;&#19979;&#26159;&#20004;&#31181;&#26041;&#27861;&#30340;&#35814;&#32454;&#35828;&#26126;&#21644;&#31034;&#20363;&#20195;&#30721;&#12290;<\/p>\n<h3>&#26041;&#27861;&#19968;&#65306;&#20351;&#29992;&#20989;&#25968;&#21435;&#25481;URL&#20013;&#30340;&#26085;&#26399;<\/h3>\n<h4>&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li>&#25171;&#24320;&#20320;&#30340;WordPress&#20027;&#39064;&#30446;&#24405;&#19979;&#30340;<code>functions.php<\/code>&#25991;&#20214;&#12290;<\/li>\n<li>&#22312;&#25991;&#20214;&#20013;&#28155;&#21152;&#20197;&#19979;&#20195;&#30721;&#65306;<\/li>\n<\/ol>\n<pre><code class=\"language-php\">function remove_date_from_url() {\n    add_filter('the_permalink', 'remove_date_from_permalink');\n}\nadd_action('after_setup_theme', 'remove_date_from_url');\n\nfunction remove_date_from_permalink($permalink) {\n    $date = get_the_time('U'); \/\/ &#33719;&#21462;&#24403;&#21069;&#26102;&#38388;&#25139;\n    if (isset($_GET['year']) &amp;&amp; isset($_GET['monthnum'])) { \/\/ &#26816;&#26597;&#26159;&#21542;&#26377;&#24180;&#20221;&#21644;&#26376;&#20221;&#21442;&#25968;\n        $date = $date + strtotime(\"+\" . ($_GET['year'] - 1900) . \" years, +\" . $_GET['monthnum'] . \" months\"); \/\/ &#35745;&#31639;&#23545;&#24212;&#26085;&#26399;\n    }\n    return str_replace('\/' . date('Y\/m\/d') . '\/', '\/', $permalink); \/\/ &#26367;&#25442;&#25481;&#26085;&#26399;&#37096;&#20998;\n}<\/code><\/pre>\n<ol start=\"3\">\n<li>&#20445;&#23384;&#24182;&#20851;&#38381;&#25991;&#20214;&#12290;<\/li>\n<\/ol>\n<h4>&#25928;&#26524;&#65306;<\/h4>\n<p>&#36825;&#20010;&#26041;&#27861;&#20250;&#22312;&#27599;&#27425;&#35775;&#38382;&#39029;&#38754;&#26102;&#37117;&#20250;&#33258;&#21160;&#21435;&#38500;URL&#20013;&#30340;&#26085;&#26399;&#37096;&#20998;&#12290;&#24403;&#29992;&#25143;&#28857;&#20987;&#38142;&#25509;&#36339;&#36716;&#21040;&#25991;&#31456;&#35814;&#24773;&#39029;&#26102;&#65292;URL&#20013;&#30340;&#26085;&#26399;&#20063;&#20250;&#34987;&#21024;&#38500;&#12290;<\/p>\n<h3>&#26041;&#27861;&#20108;&#65306;&#20351;&#29992;&#25554;&#20214;&#21435;&#25481;URL&#20013;&#30340;&#26085;&#26399;<\/h3>\n<h4>&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li>&#30331;&#24405;WordPress&#31649;&#29702;&#21518;&#21488;&#12290;<\/li>\n<li>&#36827;&#20837;&ldquo;&#25554;&#20214;&rdquo;&#33756;&#21333;&#12290;<\/li>\n<li>&#28857;&#20987;&ldquo;&#28155;&#21152;&#26032;&#25554;&#20214;&rdquo;&#65292;&#25628;&#32034;&#24182;&#23433;&#35013;&ldquo;Remove Date From Permalink&rdquo;&#25554;&#20214;&#12290;<\/li>\n<li>&#23433;&#35013;&#23436;&#25104;&#21518;&#65292;&#28608;&#27963;&#35813;&#25554;&#20214;&#12290;<\/li>\n<li>&#20351;&#29992;&#25554;&#20214;&#35774;&#32622;&#30028;&#38754;&#37197;&#32622;&#36873;&#39033;&#65292;&#36890;&#24120;&#21487;&#20197;&#22312;&ldquo;&#33258;&#23450;&#20041;&#26631;&#39064;&rdquo;&#23383;&#27573;&#36755;&#20837;&#26032;&#30340;URL&#26684;&#24335;&#65288;&#20363;&#22914;<code>\/post-title<\/code>&#65289;&#65292;&#28982;&#21518;&#28857;&#20987;&ldquo;&#24212;&#29992;&rdquo;&#12290;<\/li>\n<\/ol>\n<h4>&#25928;&#26524;&#65306;<\/h4>\n<p>&#21551;&#29992;&#27492;&#25554;&#20214;&#21518;&#65292;WordPress&#20250;&#33258;&#21160;&#22312;URL&#20013;&#21435;&#38500;&#26085;&#26399;&#37096;&#20998;&#12290;&#24403;&#20320;&#21019;&#24314;&#20102;&#19968;&#20010;&#26032;&#24086;&#23376;&#65292;&#25554;&#20214;&#20250;&#33258;&#21160;&#26356;&#26032;URL&#20197;&#19981;&#21253;&#21547;&#26085;&#26399;&#20449;&#24687;&#12290;<\/p>\n<h3>&#31034;&#20363;&#20195;&#30721;&#35828;&#26126;<\/h3>\n<ul>\n<li><code>get_the_time('U')<\/code>: &#36825;&#20010;&#20989;&#25968;&#33719;&#21462;&#24403;&#21069;&#26102;&#38388;&#25139;&#65292;&#29992;&#20110;&#35745;&#31639;&#29305;&#23450;&#26085;&#26399;&#30340;&#26102;&#38388;&#25139;&#12290;<\/li>\n<li><code>strtotime(\"+\" . ($_GET['year'] - 1900) . \" years, +\" . $_GET['monthnum'] . \" months\")<\/code>: &#26681;&#25454;&#29992;&#25143;&#25552;&#20379;&#30340;&#24180;&#20221;&#21644;&#26376;&#20221;&#21442;&#25968;&#65292;&#35745;&#31639;&#20986;&#23545;&#24212;&#30340;&#26085;&#26399;&#26102;&#38388;&#25139;&#12290;<\/li>\n<li><code>str_replace('\/' . date('Y\/m\/d') . '\/', '\/', $permalink)<\/code>: &#23558;&#21407;&#22987;&#30340;URL&#26367;&#25442;&#20026;&#19981;&#21547;&#26085;&#26399;&#30340;&#37096;&#20998;&#30340;&#26032;URL&#12290;<\/li>\n<\/ul>\n<p>&#36825;&#31181;&#26041;&#27861;&#31616;&#21333;&#26131;&#29992;&#65292;&#36866;&#29992;&#20110;&#22823;&#22810;&#25968;WordPress&#20027;&#39064;&#21644;&#25554;&#20214;&#29615;&#22659;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312;&#36825;&#20010;&#25945;&#31243;&#20013;&#65292;&#25105;&#23558;&#21521;&#24744;&#23637;&#31034;&#22914;&#20309;&#20351;&#29992;WordPress&#25554;&#20214;&#25110;&#33258;&#23450;&#20041;&#20989;&#25968;&#26469;&#20174;URL&#20013;&#31227;&#38500;&#26085;&#26399;&#37096;&#20998;&#12290;<\/p>\n<p>&#39318;&#20808;&#65292;&#25105;&#20204;&#38656;&#35201;&#23433;&#35013;&#19968;&#20010;&#21517;&#20026;<code>date&#21097;&#39192;<\/code>&#30340;&#25554;&#20214;&#12290;&#36825;&#20010;&#25554;&#20214;&#21487;&#20197;&#24110;&#21161;&#25105;&#20204;&#20174;URL&#20013;&#21024;&#38500;&#26085;&#26399;&#21644;&#26102;&#38388;&#20449;&#24687;&#12290;<\/p>\n<ol>\n<li>\n<p>&#23433;&#35013;&#26085;&#26399;&#21097;&#39192;&#25554;&#20214;&#65306;<\/p>\n<p>&#22312;WordPress&#21518;&#21488;&#65292;&#36716;&#21040;&ldquo;&#25554;&#20214;&rdquo; &gt; &ldquo;&#31649;&#29702;&rdquo; &gt; &ldquo;&#25628;&#32034;&#24182;&#23433;&#35013;&#25554;&#20214;&rdquo;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#23548;&#33322;&#33267;&#25554;&#20214;&#21015;&#34920;&#39029;&#38754;&#65292;&#28982;&#21518;&#25214;&#21040;&ldquo;&#26085;&#26399;&#21097;&#39192;&rdquo;&#25554;&#20214;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#21333;&#20987;&#25554;&#20214;&#22270;&#26631;&#65292;&#28982;&#21518;&#28857;&#20987;&ldquo;&#23433;&#35013;&rdquo;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#23433;&#35013;&#23436;&#25104;&#21518;&#65292;&#30331;&#24405;&#24744;&#30340;WordPress&#24080;&#25143;&#65292;&#36716;&#21040;&ldquo;&#25554;&#20214;&rdquo; &gt; &ldquo;&#21551;&#29992;&rdquo;&#20197;&#28608;&#27963;&#27492;&#25554;&#20214;&#12290;<\/p>\n<\/li>\n<\/ol>\n<p>&#25509;&#19979;&#26469;&#65292;&#25105;&#20204;&#23558;&#32534;&#20889;&#19968;&#20010;&#31616;&#21333;&#30340;PHP&#20989;&#25968;&#65292;&#29992;&#20110;&#21024;&#38500;&#26085;&#26399;&#21644;&#26102;&#38388;&#20174;URL&#20013;&#12290;<\/p>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<pre><code class=\"language-php\">function remove_date_from_url($url) {\n    \/\/ &#20351;&#29992;&#27491;&#21017;&#34920;&#36798;&#24335;&#21305;&#37197;&#26085;&#26399;&#23383;&#31526;&#20018;\n    $pattern = '\/(d{4})-(d{2})-(d{2})T(d{2}):(d{2}):(d{2})(?::(d{2}))?\/';\n\n    if (preg_match($pattern, $url, $matches)) {\n        \/\/ &#21024;&#38500;&#26085;&#26399;&#37096;&#20998;\n        $url = preg_replace('\/' . $pattern[0] . '\/', '', $url);\n\n        return $url;\n    }\n\n    return $url; \/\/ &#22914;&#26524;&#27809;&#26377;&#25214;&#21040;&#26085;&#26399;&#65292;&#36820;&#22238;&#21407;&#22987;URL\n}\n\n\/\/ &#31034;&#20363;&#29992;&#27861;\n$url = 'http:\/\/example.com\/2023-07-15 12:30';\n$cleaned_url = remove_date_from_url($url);\n\necho $cleaned_url; \/\/ &#36755;&#20986;&#65306;http:\/\/example.com\/2023-07-15 12:30<\/code><\/pre>\n<h3>&#35299;&#37322;&#20195;&#30721;<\/h3>\n<ul>\n<li><strong>$pattern<\/strong>&#65306;&#36825;&#26159;&#19968;&#20010;&#27491;&#21017;&#34920;&#36798;&#24335;&#65292;&#29992;&#20110;&#21305;&#37197;&#26085;&#26399;&#21644;&#26102;&#38388;&#23383;&#31526;&#20018;&#12290;<\/li>\n<li><strong>preg_match()<\/strong>&#65306;&#29992;&#20110;&#26597;&#25214;&#21305;&#37197;&#27169;&#24335;&#30340;&#23383;&#31526;&#20018;&#12290;<\/li>\n<li><strong>preg_replace()<\/strong>&#65306;&#29992;&#20110;&#26367;&#25442;&#21305;&#37197;&#30340;&#25991;&#26412;&#12290;<\/li>\n<li><strong>$matches<\/strong>&#65306;&#23384;&#20648;&#20102;&#25152;&#26377;&#21305;&#37197;&#30340;&#32452;&#65288;&#22914;&#26376;&#20221;&#12289;&#26085;&#26399;&#31561;&#65289;&#12290;<\/li>\n<li><strong>remove_date_from_url()<\/strong>&#65306;&#22788;&#29702;URL&#20013;&#30340;&#26085;&#26399;&#21644;&#26102;&#38388;&#37096;&#20998;&#12290;<\/li>\n<\/ul>\n<p>&#36825;&#20010;&#20989;&#25968;&#21487;&#20197;&#36731;&#26494;&#22320;&#24212;&#29992;&#20110;&#20219;&#20309;&#38656;&#35201;&#20174;URL&#20013;&#31227;&#38500;&#26085;&#26399;&#21644;&#26102;&#38388;&#30340;&#22330;&#26223;&#12290;&#20363;&#22914;&#65292;&#22312;&#21338;&#23458;&#25991;&#31456;&#30340;URL&#20013;&#65292;&#25105;&#20204;&#21487;&#20197;&#31227;&#38500;&#26085;&#26399;&#37096;&#20998;&#20197;&#20415;&#21482;&#26174;&#31034;&#27491;&#25991;&#12290;<\/p>\n<p>&#35831;&#27880;&#24847;&#65292;&#36825;&#31181;&#26041;&#27861;&#21487;&#33021;&#20250;&#23548;&#33268;&#19968;&#20123;&#19981;&#24076;&#26395;&#30475;&#21040;&#30340;&#20869;&#23481;&#20986;&#29616;&#22312;URL&#20013;&#65292;&#22240;&#27492;&#22312;&#23454;&#38469;&#24212;&#29992;&#20013;&#24212;&#35880;&#24910;&#20351;&#29992;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#22312;WordPress&#20013;&#65292;&#20320;&#21487;&#20197;&#36890;&#36807;&#20462;&#25913;&#27169;&#26495;&#25991;&#20214;&#25110;&#038;#2..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[59],"tuisongtax":[],"class_list":["post-2563","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-pzjc"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/comments?post=2563"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2563\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=2563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=2563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=2563"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=2563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}