How do i add an H1 tag to this echo output?

2020-05-09 21:37发布

问题:

I am having trouble adding an h1 tag to to the output of this echo. The echo is inside a larger function in my Wordpress install.

The code is part of a larger function. I've tried to enclose the echo statement in h1 tag with single quotes and double quotes. I've also tried to separate the echo inside another PHP wrapper.

<?php if ( is_tax( 'wap8-portfolio-tags' ) ) { // adds tag name to title block
        $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var('taxonomy'));
        echo $term->name;
    }

I'd like to see the echo output the variable with h1 styling.

回答1:

this should work

echo '<h1>' . $term->name . '</h1>';