2015-12-09 34 views
0

对于为什么自定义侧边栏在更新4.4后会停止在Wordpress主题中显示,您有任何初始想法吗?我们的登录/加入页面在页面右侧显示了一个自定义边栏,其中包含登录/连接表单,直到更新。这不是一个自定义的侧边栏插件,它是主题的一部分。有什么想法吗?非常感谢!自定义侧边栏随着Wordpress 4.4更新消失

可以启用默认侧边栏,但任何自定义创建的侧边栏都会呈现空白。

代码登记的functions.php内边栏:
include('functions/custom-sidebars.php');

从定制sidebars.php

全码::
`//// GETS的sidebar.php内
include('includes/sidebar/sidebar.php');

代码我们的自定义侧边栏 $ sidebars = get_option('dd_custom_sidebars');

//// IF THEY EXIST 
if($sidebars) { 

    //// LOOPS AND REGISTERS THEM 
    foreach($sidebars as $sidebar) { 

     $args = array(

      'name' => $sidebar.' — Custom', 
      'id' => us_get_sidebar_id($sidebar), 
      'description' => $sidebar.' — Custom Sidebar', 
      'before_widget' => '<div class="sidebar-item">', 
      'after_widget' => '</div>', 
      'before_title' => '<h4>', 
      'after_title' => '</h4>', 

     ); 

     //// REGISTERS IT 
     register_sidebar($args); 

    } 

} 



/// FUNCTION TO GENERATE OUR FRIENDLY NAME 
function us_get_sidebar_id($phrase) { 

    $result = strtolower($phrase); 

    $result = preg_replace("/[^a-z0-9\s-]/", "", $result); 
    $result = trim(preg_replace("/[\s-]+/", " ", $result)); 
    $result = trim(substr($result, 0, 20)); 
    $result = preg_replace("/\s/", "-", $result); 

    return $result; 

}` 
+0

我不确定你的意思,我可以在您的网站右侧看到登录表单... –

+0

这是一个添加到每个页面上显示的默认侧栏的临时表单。以前,我们为每个页面定制了侧边栏,例如您访问过的登录页面。它实际上是活跃的,但没有显示。 – JoeW

+0

在wp-config文件中启用WP-DEBUG。那么会显示错误。 –

回答

0

我有同样的问题,因为我的代码,这是创建自定义工具条是错误的,我的sidebar.php文件。 我用这个...

<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Block 3')) : ?> 

取而代之的是

<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('block-3')) : ?> 

这是侧边栏的ID从我functions.php文件

+0

谢谢nicknack。它已经工作了2年,但是,自从该网站启动以来,代码应该是这样,但似乎4.4版本中的某些东西已经被弃用了。 – JoeW

+1

你是否有你的functions.php文件中的代码注册侧边栏和在你的模板中创建边栏的代码,通常是sidebar.php? – nicknack

+0

好主意nicknack - 我已将它添加到原始帖子。 – JoeW

0

作为一个可用的解决方法(而不是一个答案为什么自定义侧边栏代码不起作用)我现在将所有各种小部件转储到默认工具条中,并使用插件Display Widgets来确定小部件显示在哪个页面上。