1

我正在尝试在我当前的店面主题中添加一个小部件区域。我使用了下面的代码,但它将小部件放在我当前的顶部标题下方,这称为辅助导航。我使用这些钩子来编写代码。

应用时,它会在辅助导航下方创建一个小部件区域,但我需要它位于辅助导航内部。任何帮助将不胜感激。

// Adding the widget area.
if (function_exists('register_sidebar')) {
    register_sidebar(array(
    'name' => 'Extra Header Widget Area',
    'id' => 'extra-widget-area',
    'description' => 'Extra widget area after the header',
    'before_widget' => '<div class="widget my-extra-widget">',
    'after_widget' => '</div>',
    'before_title' => '<h2>',
    'after_title' => '</h2>'
    ));
}


// placing the widget
add_action ('storefront_header', 'add_my_widget_area', 10);
function add_my_widget_area() {
  if (function_exists('dynamic_sidebar')) {
    dynamic_sidebar('Extra Header Widget Area');
  }
}
4

1 回答 1

1

您将需要像这样更改优先级5159例如:

add_action ('storefront_header', 'add_my_widget_area', 55);

因为在storefront_header钩子中,这些是当前的优先级:

for 'storefront_header' hook:
@hooked ‘storefront_skip_links’, 0
@hooked ‘storefront_social_icons’, 10
@hooked ‘storefront_site_branding’, 20
@hooked ‘storefront_secondary_navigation’, 30
@hooked ‘storefront_product_search’, 40
@hooked ‘storefront_primary_navigation’, 50
@hooked ‘storefront_header_cart’, 60

!important然后,您将需要使用在某些规则中强制执行的自定义 css 规则来优化显示。

于 2016-05-28T16:45:58.930 回答