wordpress判断是否启用伪静态或固定链接类型
wordpress判斷是否啟用偽靜態(tài)或固定鏈接類型
有時(shí)候需要判斷wordpress站點(diǎn)是否設(shè)置了偽靜態(tài)
,即后臺(tái)固定鏈接設(shè)置中的選擇了非”默認(rèn)”的結(jié)構(gòu)。
下面看一下判斷方法:
<?php
if(get_option('permalink_structure') == ''){
echo '使用的是默認(rèn)設(shè)置';
}elseif(get_option('permalink_structure') == '/%year%/%monthnum%/%day%/%postname%/'){
echo '日期和名稱型';
}elseif(get_option('permalink_structure') == '/%year%/%monthnum%/%postname%/'){
echo '月份和名稱型';
}elseif(get_option('permalink_structure') == '/archives/%post_id%'){
echo '數(shù)字型';
}elseif(get_option('permalink_structure') == '/%postname%/'){
echo '文章名';
}else{
echo '自定義結(jié)構(gòu)';
}
?>
若是只寫get_option(‘permalink_structure’) 判斷是否是自定義結(jié)構(gòu) 。
展開閱讀全文投稿時(shí)間:2022-05-26 最后更新 :2022-09-05
.jpg)