2016-03-18 19 views
2

使用Wordpress插件根據自定義分類標準對自定義帖子類型進行排序。結果將在帖子類型的歸檔頁面上返回。排序是偉大的工作,但遭到阻攔試圖與多個分類項目顯示標題內容:基於strstr的多個url值的內容可見性?

<?php if(strstr($_SERVER['REQUEST_URI'], "level/invigorating")) { ?> 
<h3>These poses are invigorating:</h3> 
<?php } ?> 

<?php if(strstr($_SERVER['REQUEST_URI'], "level/invigorating/position/seated")) { ?> 
<h3>These poses are invigorating and seated:</h3> 
<p>For positions of this nature please take care of your sacrum.</p> 
<?php } ?> 

<?php if(strstr($_SERVER['REQUEST_URI'], "position/seated")) { ?> 
<h3>These poses are seated:</h3> 
<?php } ?> 

"level/invigorating/position/seated"返回下面的三個h3的,因爲所有的if的迴歸真實。

我的PHP技巧很糟糕,試圖理解手冊就像盯着夜空。

這怎麼寫,所以每頁只能返回一個值?可能this screenshot幫助。使用Beautiful Taxonomy Filters

+0

我不知道我理解這個問題的權利,但我會建議作出自定義後鍵入https使用WordPress的層次://developer.wordpress.org/files/2014/10/template-hierarchy.png – meck373

+0

謝謝!我相信模板工作正常。我可能可以忽略關於帖子類型和分類法的所有內容,但我想解釋這些網址。 – shipwreck

回答

1

我相信你正在嘗試做的是這樣的......

<?php if(strstr($_SERVER['REQUEST_URI'], "level/invigorating/position/seated")) { ?> 
<h3>These poses are invigorating and seated:</h3> 
<p>For positions of this nature please take care of your sacrum.</p> 
<?php } elseif(strstr($_SERVER['REQUEST_URI'], "level/invigorating")) { ?> 
<h3>These poses are invigorating:</h3> 
<?php } elseif(strstr($_SERVER['REQUEST_URI'], "position/seated")) { ?> 
<h3>These poses are seated:</h3> 
<?php } ?> 
+0

謝謝!這就是我的想法,但無法實現。非常感謝善良的先生。 – shipwreck