Php 有条件发行(如果,否则)
打了一个小嗝。我在wordpress仪表板中创建了4个文本框,每个文本框对应于页面模板上的if/else条件 在仪表板控制端Php 有条件发行(如果,否则),php,wordpress,Php,Wordpress,打了一个小嗝。我在wordpress仪表板中创建了4个文本框,每个文本框对应于页面模板上的if/else条件 在仪表板控制端 array( "name" => "Antique", "desc" => "Enter content for Antique Rugs here.", "id" => $shortname."_antique", "std" => "", "type" => "te
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_页面值是相关页面的标题。获取主题选项是选项/内容
现在,其中三个条件完美地发挥了作用;当代、复古和销售都会按预期显示内容。然而,当我试图查看古董内容时,它会转到else fall back,只是说没有内容。我已经盯着它看了一段时间了,所以这可能只是我忽略的一个愚蠢的打字错误,但是有人能看到这个错误吗你确实尝试过洗牌if语句(即将“古董”块移到else if,等等),对吗?我想问题可能出在别的地方是的,我以前确实试过。我发现网站没有特别阅读古董部分。我删除并重新键入了整个数组选项部分,因为我认为这是一个我没有看到的打字错误,但从我现在看到的内容来看,所有内容都正确地键入了。在这种情况下它仍然不会输出:如果(是页面(‘古董’)Mhm,那么错误不在代码中,afaict,查看页面标题,等等,任何与其他不同的方式。哇,好的。我刚把它修好。。。这也是最愚蠢的错误。这一页的标题是“古董”,末尾有一个额外的空格,这使它在搜索“古董”页时的情况变得糟糕在过去的一个小时里,我一直在一遍又一遍地讨论这件事,一直都是那个愚蠢的疏忽。谢谢你花时间来研究它,不过很高兴你能解决它。。