I am creating a plugin and I want to create a full-width div at the bottom of the header. I tried wp_head action but it is adding the div at the top of the header.
The question is how can i add a div at the bottom/end of header with php code? Is there any wordpress hook or filter which I can use? Thanks in advance.
Currently, it appears like this.
But I want to move the breaking section below the header.
2
Answers
Actually, there is no available WordPress hook that will run right after the WordPress header.php loads.
I implemented this by appending the HTML code below the header using javascript.
You can find the code here. https://github.com/AwaisTheDev/wordpress_breaking_news_plugin/blob/main/includes/load-widget-frontend.php#L82
wp_body_open
fires after the opening body tag but the header is after the tag. The action hook that fires afterget_header
would beloop_start
, unless the theme has a hook added in between. Also make sure to set the priority so the hook loads first.Styles
Function and hook