Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Wordpress中添加或使用SMOF复选框_Wordpress - Fatal编程技术网

如何在Wordpress中添加或使用SMOF复选框

如何在Wordpress中添加或使用SMOF复选框,wordpress,Wordpress,我的主题选项使用了稍微修改过的选项框架。我想在我的主题中显示/隐藏我的菜单栏。我想使用复选框或切换到打开/关闭菜单栏。我已经有了smof函数的有害程序代码 $of_options[] = array( "name" => "Primary Menu Enabled?", "desc" => "Please, use the menus panel to manage and organize menu items for

我的主题选项使用了稍微修改过的选项框架。我想在我的主题中显示/隐藏我的菜单栏。我想使用复选框或切换到打开/关闭菜单栏。我已经有了smof函数的有害程序代码

$of_options[] = array(  "name"      => "Primary Menu Enabled?",
                    "desc"      => "Please, use the menus panel to manage and organize menu items for the primary menu.",
                    "id"        => "menu_primary_enable",
                    "std"       => 1,
                    "type"      => "checkbox"
            );
还有一个选项出现在我的主题选项中。这是我的菜单栏代码

      <?php 
if (function_exists('wp_nav_menu')) {
wp_nav_menu( array( 
    'theme_location' => 'menu-primary', 
    'container_class' => 'menu-primary-container',
    'items_wrap'      => '<ul class="menus menu-primary sub-menu sf-js-enabled">%3$s</ul>', 
    'fallback_cb' => 'cdb_default_menu'));
            }
            else {
                cdb_default_menu();
            } 

    ?>

我只是想办法。我使用了以下代码:

<?php global $data; ?>
<?php if($data['your_option_id']): ?>
<......Something here.....>
<?php endif; ?>

菜单栏代码如下

<?php global $data; ?>
<?php if($data['menu_primary_enable']): ?>

<?php 
if (function_exists('wp_nav_menu')) {
wp_nav_menu( array( 
    'theme_location' => 'menu-primary', 
    'container_class' => 'menu-primary-container',
    'items_wrap'      => '<ul class="menus menu-primary sub-menu sf-js-enabled">%3$s</ul>', 
    'fallback_cb' => 'cdb_default_menu'));
            }
            else {
                cdb_default_menu();
            } 

    ?>

<?php endif; ?>