打了一下打嗝。我在wordpress仪表板中创建了4个文本框,每个文本框对应于页面模板上的if / else条件。
在仪表板控件端,
array( "name" => "Antique",
"desc" => "Enter content for Antique Rugs here.",
"id" => $shortname."_antique",
"std" => "",
"type" => "textarea"),
array( "name" => "Contemporary",
"desc" => "Enter content for Contemporary Rugs here.",
"id" => $shortname."_contemporary",
"std" => "",
"type" => "textarea"),
array( "name" => "Vintage",
"desc" => "Enter content for Vintage Rugs here.",
"id" => $shortname."_vintage",
"std" => "",
"type" => "textarea"),
array( "name" => "Custom",
"desc" => "Enter content for Custom Rugs here.",
"id" => $shortname."_custom",
"std" => "",
"type" => "textarea"),
(最后一个之后还有更多的项目,这就是那个悬挂逗号的内容)。在此内容将放置的实际模板上,
if (is_page('Antique'))
{
if (get_theme_option('antique') != '')
{echo 'antique';}
}
else if (is_page('Contemporary'))
{
if (get_theme_option('contemporary') != '')
{echo 'contemporary';}
}
else if (is_page('Vintage'))
{
if (get_theme_option('vintage') != '')
{echo 'vintage';}
}
else if (is_page('Custom'))
{
if (get_theme_option('custom') != '')
{echo 'custom';}
}
else
{echo "no content";}
is_page值是相关网页的标题。获取主题选项是选项/内容
现在,其中三个条件完美无瑕;现代,复古和销售都按预期显示内容。然而,当我试图查看古董内容时,它会转向其他后退,并且只是说没有内容。我一直在盯着这一段时间,所以这可能只是我忽略的一个愚蠢的错字,但任何人都可以看到这个错误