Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionHTML:
<header>
<!-- I want to add html code here -->
</header>
Function:
function add_html_to_header {
<b> Hello World </b>
}
add_action('','add_html_to_header')
Expected Html results:
<header id="header">
<b> Hello World </b>
</header>
EDIT: Is it possible without using Javascript
?
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionHTML:
<header>
<!-- I want to add html code here -->
</header>
Function:
function add_html_to_header {
<b> Hello World </b>
}
add_action('','add_html_to_header')
Expected Html results:
<header id="header">
<b> Hello World </b>
</header>
EDIT: Is it possible without using Javascript
?
2 Answers
Reset to default 4You can add html to the site head using this function:
// Add scripts to wp_head()
function add_head_html() { ?>
<!-- html goes here -->
<?php }
add_action( 'wp_head', 'add_head_html' );
But if you're talking about the html element <header>
(as it sounds like from your edits) it sounds like overcomplicating things, but you might want to look at injecting it with jquery into the right spot using a solution such as this:
https://stackoverflow/a/9866637/3387817
You can use action hooks:
<header>
<!-- I want to add html code here -->
<?php do_action('wpse_myheader'); ?>
</header>
Then you can use:
function add_html_to_header { ?>
<b> Hello World </b>
<?php }
add_action('wpse_myheader','add_html_to_header');
error_reporting(E_ALL);
andWP_DEBUG
. You'll see your syntax is seriously bad. – Max Yudin Commented Sep 3, 2017 at 10:32