PHP默认显示(调用还是数组?) [英] PHP to Show By Default (Call or array?)

查看:80
本文介绍了PHP默认显示(调用还是数组?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这比WordPress问题更像是一个PHP问题,但我在WP主题中使用它。

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();
} ?>


推荐答案

这可能应该有效

if ( get_option('to_breadcrumbs') != 'No' ) {

这篇关于PHP默认显示(调用还是数组?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆