PHP 默认显示(调用还是数组?)
这更像是一个 PHP 问题,而不是 WordPress 问题,但我在 WP 主题中使用它。
在我的选项中,我允许用户显示/隐藏面包屑。但是,当尚未选择和保存任何首选项时(例如,如果有人要安装主题),默认情况下不会显示面包屑......我希望它们如此。
下面是我的代码。我确信我只是在这里遗漏了一小段代码...
这是我正在使用的数组:
array( "name" => "Display breadcrumbs on post pages?",
"desc" => "Choose whether or not to display breadcrumbs, that is, the post trail.",
"id" => $shortname."_breadcrumbs",
"type" => "select",
"options" => array("Yes", "No"),
"std" => "Yes"),
这是我在帖子中调用面包屑的方式:
<?php
if ( get_option('to_breadcrumbs') == 'Yes' ) {
if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs();
} ?>
This is more of a PHP question than a WordPress question, but I am using it in a WP theme.
In my options I am allowing users to show/hide breadcrumbs. However, when there are no preferences yet selected and saved (for example, if somebody were to install the theme) the breadcrumbs aren't displayed by default... and I would like them to be.
Below is my code. I'm confident I'm just missing a very small piece of code here...
Here is the array I am using:
array( "name" => "Display breadcrumbs on post pages?",
"desc" => "Choose whether or not to display breadcrumbs, that is, the post trail.",
"id" => $shortname."_breadcrumbs",
"type" => "select",
"options" => array("Yes", "No"),
"std" => "Yes"),
Here is how I am calling the breadcrumbs in my posts:
<?php
if ( get_option('to_breadcrumbs') == 'Yes' ) {
if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs();
} ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能应该有效
This should probably work
尝试使用 默认 值:
如果这不起作用,请尝试将其放入并查看它是什么印刷:
Try using a default value:
If that doesn't work, try putting this in and see what it prints: