I have a header file in WordPress theme which always shows site title after the creation of a new page because of code <?php echo esc_html( get_bloginfo( 'name' ) ); ?>
but I want it to replace with current page title instate of site name so, what would be PHP code for that?
I have a header file in WordPress theme which always shows site title after the creation of a new page because of code <?php echo esc_html( get_bloginfo( 'name' ) ); ?>
but I want it to replace with current page title instate of site name so, what would be PHP code for that?
1 Answer
Reset to default -2Try below code.
global $post;
echo esc_html( get_the_title($post->ID) );
<title>
tag? – Jacob Peattie Commented Nov 12, 2018 at 6:24