最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How to remove the h6 tag for the entry-category Class

programmeradmin1浏览0评论

On my single blog pages at the very beginning, I have the html

<h6 class="entry-category is-xsmall">
    <a href="www.website" rel="category tag">category title</a></h6>

I want to remove the h6 tag from all blog pages. In this forum, I found a solution for removing the h3 at the comments:

    function my_comment_form_before() {
    ob_start();
}
add_action( 'comment_form_before', 'my_comment_form_before' );

function my_comment_form_after() {
    $html = ob_get_clean();
    $html = preg_replace(
        '/<h3 id="reply-title"(.*)>(.*)<\/h3>/',
        '<p id="reply-title"\1>\2</p>',
        $html
    );
    echo $html;
}
add_action( 'comment_form_after', 'my_comment_form_after' );

I tried to change it to the h6 problem:

function my_comment_form_before() {
        ob_start();
    }
    add_action( 'comment_form_before', 'my_comment_form_before' );
    
    function my_comment_form_after() {
        $html = ob_get_clean();
        $html = preg_replace(
            '/<h6 class="entry-category is-xsmall"(.*)>(.*)<\/h6>/',
            '<p id="reply-title"\1>\2</p>',
            $html
        );
        echo $html;
    }
    add_action( 'comment_form_after', 'my_comment_form_after' );

But it is not removing the h6. How can I remove it the right way?

On my single blog pages at the very beginning, I have the html

<h6 class="entry-category is-xsmall">
    <a href="www.website" rel="category tag">category title</a></h6>

I want to remove the h6 tag from all blog pages. In this forum, I found a solution for removing the h3 at the comments:

    function my_comment_form_before() {
    ob_start();
}
add_action( 'comment_form_before', 'my_comment_form_before' );

function my_comment_form_after() {
    $html = ob_get_clean();
    $html = preg_replace(
        '/<h3 id="reply-title"(.*)>(.*)<\/h3>/',
        '<p id="reply-title"\1>\2</p>',
        $html
    );
    echo $html;
}
add_action( 'comment_form_after', 'my_comment_form_after' );

I tried to change it to the h6 problem:

function my_comment_form_before() {
        ob_start();
    }
    add_action( 'comment_form_before', 'my_comment_form_before' );
    
    function my_comment_form_after() {
        $html = ob_get_clean();
        $html = preg_replace(
            '/<h6 class="entry-category is-xsmall"(.*)>(.*)<\/h6>/',
            '<p id="reply-title"\1>\2</p>',
            $html
        );
        echo $html;
    }
    add_action( 'comment_form_after', 'my_comment_form_after' );

But it is not removing the h6. How can I remove it the right way?

Share Improve this question asked Oct 6, 2020 at 7:31 flxflx 1 1
  • What's generating the h6? I can't see <h6 class="entry-category is-xsmall"> in any of the core WordPress files, so I'd guess it's your theme? You probably want to make a child theme and override whichever template that is. – Rup Commented Oct 6, 2020 at 23:53
Add a comment  | 

1 Answer 1

Reset to default 1

You don't need functions for this, just look in your theme's template files: For single posts check single.php and for blog archive/categories check archive.php.

Change the <h6> in those php files to <div> or whatever you want. It would be wiser to override them with a child theme so you don't lose your changes in a future update of the theme.

发布评论

评论列表(0)

  1. 暂无评论