{"id":1415,"date":"2021-02-11T15:53:28","date_gmt":"2021-02-11T22:53:28","guid":{"rendered":"https:\/\/kadence-theme.com\/?post_type=knowledgebase&#038;p=1415"},"modified":"2022-06-30T03:54:45","modified_gmt":"2022-06-30T03:54:45","password":"","slug":"changing-various-heading-html-tags","status":"publish","type":"docs","link":"https:\/\/www.kadencewp.com\/help-center\/docs\/kadence-theme\/changing-various-heading-html-tags\/","title":{"rendered":"Changing Various Heading HTML Tags"},"content":{"rendered":"\n<p>Changing the markup isn&#8217;t always a good idea, you can hurt your accessibility score by changing the <a aria-label=\"sequentially-descending order (opens in a new tab)\" href=\"https:\/\/web.dev\/heading-order\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\" class=\"rank-math-link\">sequentially-descending order<\/a>. However, some people want to do this or they want to change the text output. In this tutorial, we will look at changing the headings HTML tag and where applicable the headings text in 4 common areas of interest. Related Posts, Comments, Comments Leave a reply, and Widget titles. This is all done using PHP filters and these are best added by using a <a href=\"https:\/\/kadence-theme.com\/knowledge-base\/advanced\/how-to-add-a-custom-filter-or-function-with-code-snippets\/\" class=\"rank-math-link\" target=\"_blank\" rel=\"noopener\">code snippet plugin<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Change the Similar Posts Title<\/h2>\n\n\n\n<p>If you just want to change the heading for &#8220;Similar Posts&#8221; to use a different html tag, for example an h4 tag, you can use this filter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/**\n * Change the similar posts title output.\n *\n * @param string $html the output html.\n *\/\nfunction custom_similar_posts_title( $html ) {\n    $html = '&lt;h4 class=\"entry-related-title\"&gt;' . esc_html__( 'Similar Posts', 'custom-text-domain' ) . '&lt;\/h4&gt;';\n    return $html;\n}\nadd_filter( 'kadence_single_post_similar_posts_title', 'custom_similar_posts_title' );<\/code><\/pre>\n\n\n\n<p>If instead you want to change the text output to read Similar Posts to {post-title} where post title is the current posts title you can use a filter like this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/**\n * Change the similar posts title output.\n *\n * @param string $html the output html.\n *\/\nfunction custom_similar_posts_title( $html ) {\n    $html = '&lt;h2 class=\"entry-related-title\"&gt;' . esc_html__( 'Similar Posts to', 'custom-text-domain' ) . ' ' . get_the_title() . '&lt;\/h2&gt;';\n    return $html;\n}\nadd_filter( 'kadence_single_post_similar_posts_title', 'custom_similar_posts_title' );<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How to Change the Comments Title<\/h2>\n\n\n\n<p id=\"block-ea28ae3b-4baf-427a-87b1-33b216e339c2\">If you just want to change the heading for &#8220;One Comment&#8221; to use a different html tag, for example an h4 tag, you can use this filter.<\/p>\n\n\n\n<pre id=\"block-467da6ed-7cd5-473b-a43e-e8f84ae0507c\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/**\n * Change the post comments title output.\n *\n * @param string $html the output html.\n *\/\nfunction custom_post_comments_title( $html ) {\n    $html = '&lt;h4 class=\"comments-title\"&gt;';\n    $comment_count = (int) get_comments_number();\n    if ( 1 === $comment_count ) {\n        $html .= esc_html__( 'One Comment', 'kadence' );\n    } else {\n        $html .= sprintf(\n            \/* translators: 1: comment count number *\/\n            esc_html( _nx( '%1$s Comment', '%1$s Comments', $comment_count, 'comments title', 'kadence' ) ),\n            number_format_i18n( $comment_count )\n        );\n    }\n    $html .= '&lt;\/h4&gt;&lt;!-- .comments-title --&gt;';\n    return $html;\n}\nadd_filter( 'kadence_single_post_comments_title', 'custom_post_comments_title' );<\/code><\/pre>\n\n\n\n<p id=\"block-73b05a49-cb16-4e7f-b0f1-a103be637f74\">If instead you want to change the text output to read One Comment to {post-title} where post title is the current posts title you can use a filter like this.<\/p>\n\n\n\n<pre id=\"block-6d9af5d2-98cf-4fae-ae17-e8ae86ce15ee\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/**\n * Change the post comments title output.\n *\n * @param string $html the output html.\n *\/\nfunction custom_post_comments_title( $html ) {\n    $html = '&lt;h2 class=\"comments-title\"&gt;';\n    $comment_count = (int) get_comments_number();\n    if ( 1 === $comment_count ) {\n        $html .= esc_html__( 'One Comment', 'kadence' );\n    } else {\n        $html .= sprintf(\n            \/* translators: 1: comment count number *\/\n            esc_html( _nx( '%1$s Comment', '%1$s Comments', $comment_count, 'comments title', 'kadence' ) ),\n            number_format_i18n( $comment_count )\n        );\n    }\n    $html .= ' ' . esc_html__( 'on', 'kadence' ) . ' ' . get_the_title();\n    $html .= '&lt;\/h2&gt;&lt;!-- .comments-title --&gt;';\n    return $html;\n}\nadd_filter( 'kadence_single_post_comments_title', 'custom_post_comments_title' );<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How to Change the Leave a Reply Heading Tag<\/h2>\n\n\n\n<p>To change the comments &#8220;Leave a Reply&#8221; heading tag to use an h4 html tag you can use this filter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/**\n * Change the comment form title HTML tag.\n *\n * @param array $args the comment form args.\n *\/\nfunction custom_commentform_title_tag( $args ) {\n    $args['title_reply_before'] = '&lt;h4 id=\"reply-title\" class=\"comment-reply-title\"&gt;';\n    $args['title_reply_after']  = '&lt;\/h4&gt;';\n    return $args;\n}\nadd_filter( 'comment_form_defaults', 'custom_commentform_title_tag' );<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How to Change the Widget Title Heading Tag<\/h2>\n\n\n\n<p>To change the widget title heading html tag to h4 for example you can use this filter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/**\n * Change the widget area title HTML tags.\n *\n * @param array $args the widget area args.\n *\/\nfunction custom_widget_title_args( $args ) {\n  $args['before_title'] = '&lt;h4 class=\"widget-title\"&gt;';\n  $args['after_title'] = '&lt;\/h4&gt;';\n  return $args;\n}\nadd_filter( 'kadence_widget_area_args', 'custom_widget_title_args' );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Changing the markup isn&#8217;t always a good idea, you can hurt your accessibility score by changing the sequentially-descending order. However, some people want to do this or they want to change the text output. In this tutorial, we will look at changing the headings HTML tag and where applicable the headings text in 4 common&#8230;<\/p>\n","protected":false},"author":1265,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"doc_category":[405],"doc_tag":[],"knowledge_base":[6],"class_list":["post-1415","docs","type-docs","status-publish","hentry","doc_category-theme-advanced","knowledge_base-kadence-theme"],"year_month":"2026-04","word_count":671,"total_views":"5160","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"display_name":"Ben Ritner","author_link":"https:\/\/www.kadencewp.com\/help-center\/author\/britner\/"},"doc_category_info":[{"term_name":"Advanced","term_url":"https:\/\/www.kadencewp.com\/help-center\/knowledge-base\/kadence-theme\/theme-advanced\/"}],"doc_tag_info":[],"knowledge_base_info":[{"term_name":"Kadence Theme","term_url":"https:\/\/www.kadencewp.com\/help-center\/knowledge-base\/kadence-theme\/","term_slug":"kadence-theme"}],"knowledge_base_slug":["kadence-theme"],"taxonomy_info":{"doc_category":[{"value":405,"label":"Advanced"}],"knowledge_base":[{"value":6,"label":"Kadence Theme"}]},"featured_image_src_large":false,"comment_info":0,"_links":{"self":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/1415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/users\/1265"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/comments?post=1415"}],"version-history":[{"count":1,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/1415\/revisions"}],"predecessor-version":[{"id":5362,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/1415\/revisions\/5362"}],"wp:attachment":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/media?parent=1415"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/doc_category?post=1415"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/doc_tag?post=1415"},{"taxonomy":"knowledge_base","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/knowledge_base?post=1415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}