簡體   English   中英

當站點不在根域上時,如何確保相對URL有效?

[英]How to make sure relative URL works when site is not on root domain?

我只是嘗試將主題安裝在域子目錄中的另一個WP安裝中。 我從未真正對子目錄進行過認真的思考,但是它確實發生了,所以我知道我需要對其進行更改。 由於我計划分發主題,因此絕對URLS不可行。

這里要注意的是,URL需要在數組內更具體地使用某些主題設置來工作。 這是它們的外觀。

function mytheme_get_theme_mods() {
$defaults = array(
'mytheme_header_logo'                => '/wp-content/themes/mytheme/img/logo.png',
'mytheme_footer_logo'                => '/wp-content/themes/mytheme/img/footerlogo.png',
'mytheme_middle_image'                => '/wp-content/themes/mytheme/img/middleimg.png'

);

return $defaults;

}

誰能幫我嗎?

嘗試這個:

     function mytheme_get_theme_mods() {
 $defaults = array(
'mytheme_header_logo'                => get_theme_root_uri().'/mytheme/img/logo.png',
'mytheme_footer_logo'                => get_theme_root_uri().'/mytheme/img/footerlogo.png',
'mytheme_middle_image'                => get_theme_root_uri().'/mytheme/img/middleimg.png'

);

return $defaults;
}

如果您想查看數組的輸出位置'print_r($ defaults);' 在return下方,然后在index.php中調用該函數,它將在查找圖像的位置打印確切的URL。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM