WordPress: невозможно изменить аргументы the_widget - PullRequest
0 голосов
/ 06 марта 2020

Привет, ребята. Я пытаюсь изменить функцию h2 в h5 на the_widget, которую я хочу отобразить на странице 404 в качестве полезной ссылки, но она не работает:

<?php
$args = array(
    'before_widget' => '<div class="widget %s">',
    'after_widget' => '</div>',
    'before_title' => '<h5 class="widget-title">',
    'after_title' => '</h5>'
);
the_widget('WP_Widget_Pages', $args);
?>

Я пробовал выше, но ничего не меняется. Может кто-нибудь помочь? Я новичок в WordPress. Спасибо.

1 Ответ

0 голосов
/ 06 марта 2020

Я обычно делаю это так:

add_action( 'widgets_init', 'theme_slug_widgets_init' );
function theme_slug_widgets_init() {
    register_sidebar( array(
        'name' => 'my_sidebar_1',
        'id' => 'sidebar_1',
        'description' => __( 'Widgets in this area will be shown on all blog posts.', 'theme-slug' ),
        'before_widget' => '<div class="widgetwrapper">',
        'after_widget'  => '</div>',
        'before_title'  => '<h5 class="widget-title">',
        'after_title'   => '</h5>',
    ) );
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...