我想在相關帖子的主題中作出選項 我想顯示兩個不同的相關帖子,一個是通過標籤和其他類別,但我想給出從主題選擇它的可能性面板
我在relatedposts.php代碼
$relatedposts = get_option('theme_relatedoptions');
if (get_option('theme_relatedoptions') <> '') {
get_template_part('templates/related/'.$relatedposts.'', get_post_format());
} else {
get_template_part('templates/related/tags', get_post_format());
}
守則管理功能
$options[] = array("name" => __('Related Videos','framework'),
"id" => $shortname."_relatedoptions",
"type" => "radio",
"options" => array("tags", "category"),
"std" => "tags");
tags.php相關文件夾顯示我不知道在哪裏, 我不確定在這裏 get_template_part('templates/related /'.$ relatedposts。'',get_post_format());
任何人都可以幫助我嗎?感謝
有另一種方式,而不是使用get_template_part使這個?因爲正如你在管理中看到的,我有「選項」=>數組(「標籤」,「類別」),所以當我選擇類別時,我希望關係變更爲category.php,類似'$ variable'.php對不起,我是一個初學者 – giuseppe23 2015-02-10 19:14:01
不需要爲成爲首發的人道歉,我們都曾經是首發:)我需要道歉,因爲我認爲我誤解了你的問題並給了你一個不正確的答案。你能否澄清這個問題對我來說有點困難?您是否說要在頁面上顯示特定標籤或類別的帖子(由用戶在儀表板的選項頁面上設置)?您希望顯示哪個頁面,因爲這會影響您需要放置代碼的位置,以及您在引用的模板中有什麼內容? – 2015-02-10 20:24:04
感謝您的答覆測試,測試和測試finaly我想出了另一種方式'$ relatedposts = get_option('theme_relatedoptions');如果($ relevantposts ==「tags」){ get_template_part('inc/related/tags',get_post_format()); ('templates // related/category',get_post_format());}} elseif($ related_by ==「category」){ } elseif($ related_by ==「category」){ get_template_part其他{ get_template_part('templates // related/tags',get_post_format()); }'謝謝 – giuseppe23 2015-02-10 22:34:47