WordPress.org

Make WordPress Core

#21953 closed enhancement (duplicate)

add action after get_header

Reported by: thomask Owned by:
Milestone: Priority: normal
Severity: trivial Version:
Component: Bundled Theme Keywords:
Focuses: Cc:

Description

It is several time i came on this - i quite often need to print something after header, but before the actual content. Problem is, that every template looks like

get_header(); ?>

	<div id="primary" class="site-content">

but the start of the main content is at the end of header.php

...
	<div id="main" class="wrapper">

the get_header function is quite "stupid", just calls an action BEFORE the header (for HTTP headers), but there is no action after it, nor filter to update returned header.

That's the only only place in whole template structure, where i cannot add anything (and placing something above the content but bellow header is quite often), and i would have to

a) change all templates (create child ones)

b) or change (child) header.php template

So the only was is to copy the header.php to child theme and add something after it, what is very ofter "too much" when i e.g. want to place there some banner, which I cant position using css because e.g. unknown height. And copying quite complex structure of header.php is also not ideal solution, as header part is very often diferent theme by theme and version by version.

So best would be to add some action in header.php just after everything else before that <div id="main" class="wrapper">

...
	</header><!-- #masthead -->
	<?php do_action( 'after_header' ); ?>
	<div id="main" class="wrapper">

Change History (1)

comment:1 SergeyBiryukov19 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version trunk deleted

Duplicate of #21506.

Note: See TracTickets for help on using tickets.