Support » Developing with WordPress » i want change h2 tag of dynamic sidebar.but before_title not work.

  • bgeg


    i want change h2 element of dynamic sidebar.
    i think it not good for search engine.

    before_widget and after_widget key work well with the code written below.
    but before_title and after_title key not work.
    please tell me the some advice.

    # sidebar.php
    <?php dynamic_sidebar( 'sidebar1' ); ?>

    # function.php

    if (function_exists('register_sidebar')) {
    	   'name' => 'sidebar_one',
    	   'id' => 'sidebar1',
    	   'description' => 'this is sidebar1',
    	   'before_widget'=>'<nav class="sidebar__wrapper">',
    	   'before_title'=>'<h2 class="sidebar__title">',

    # image of result

Viewing 6 replies - 1 through 6 (of 6 total)
  • Vijay Hardaha


    It’s different in block editor widgets, You can click on title then change the title tag in block editor

    Thread Starter bgeg


    >>Vijay Hardaha (@vijayhardaha)
    thanks for comment.
    i can change h2 tag of sidebar in block editor.
    before_title and after_title function disabled in now wordpress?

    Moderator bcworkz


    I have a child theme of twenty twenty-one. Your code works as expected there. I only changed the sidebar ID so it does not conflict with sidebars already registered.

    Thread Starter bgeg


    >>bcworkz (@bcworkz)
    thanks for comment.
    i used original theme.
    it may have some problem.


    before_title and after_title still work with classic widgets.

    Thread Starter bgeg


    >>Vijay Hardaha (@vijayhardaha)
    thanks for comment.
    probably i missed code something.
    i will try to improve something.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.