-
Notifications
You must be signed in to change notification settings - Fork 6
Hooks—Header and Footer
ucfwp_get_header_images_before
ucfwp_get_header_images_after
ucfwp_get_header_videos_before
ucfwp_get_header_videos_after
ucfwp_get_header_title_before
ucfwp_get_header_title_after
ucfwp_get_header_subtitle_before
ucfwp_get_header_subtitle_after
Deprecated in v0.7.3-- Use wp_body_open
instead.
This action executes in header.php, immediately below where the university header renders, and immediately above the site header/navigation. Use it to echo markup or scripts that have to be placed after the document's opening <body>
tag.
n/a
// Echo text immediately above the site header (below the university header)
function pre_header_content() {
echo '...';
}
add_action( 'after_body_open', 'pre_header_content' );
Allows for early overriding of the per-breakpoint header images that are fetched for a given post or term object.
-
$images
arrayAn associative array of image size strings and the attachment IDs for those sizes, before custom meta values are retrieved. Expected format:
array( 'header_image' => '', 'header_image_xs' => '' )
-
$obj
objectThe current
WP_Post
orWP_Term
object
array: An associative array of image size strings and the attachment IDs for those sizes
// Enforce a consistent set of header images for all 'person' posts,
// regardless of page meta field values available/set.
function person_header_images( $images, $obj ) {
if ( $obj instanceof WP_Post && $obj->post_type === 'person' ) {
$person_header_img = 1234; // Replace value with an actual attachment ID, e.g. fetched from a Customizer option
$person_header_img_xs = 5678; // Replace value with an actual attachment ID, e.g. fetched from a Customizer option
$images['header_image'] = $person_header_img;
$images['header_image_xs'] = $person_header_image_xs;
}
return $images;
}
add_filter( 'ucfwp_get_header_images_before', 'person_header_images', 10, 2 );
Allows for late overriding of the per-breakpoint header images that are fetched for a given post or term object.
-
$images
arrayAn associative array of image size strings and the attachment IDs for those sizes. Expected format:
array( 'header_image' => '', 'header_image_xs' => '' )
-
$obj
objectThe current
WP_Post
orWP_Term
object
array: An associative array of image size strings and the attachment IDs for those sizes
// Apply a set of fallback header images if the post/term
// doesn't already have its own header_image size defined
function fallback_header_images( $images, $obj ) {
// 'header_image' size is required for any header image to be displayed
if ( ! isset( $images['header_image'] ) || empty( $images['header_image'] ) ) {
$fallback_header_img = 1234; // Replace value with an actual attachment ID, e.g. fetched from a Customizer option
$fallback_header_img_xs = 5678; // Replace value with an actual attachment ID, e.g. fetched from a Customizer option
$images['header_image'] = $fallback_header_img;
$images['header_image_xs'] = $fallback_header_image_xs;
}
return $images;
}
add_filter( 'ucfwp_get_header_images_after', 'fallback_header_images', 10, 2 );
Allows for early overriding of the header videos that are fetched for a given post or term object.
-
$videos
arrayAn associative array of video type strings and the attachment urls for those sizes, before custom meta values are retrieved. Expected format:
array( 'webm' => '', 'mp4' => '' )
-
$obj
objectThe current
WP_Post
orWP_Term
object
array: An associative array of video type strings and the urls for those types
Called in ucfwp_get_header_videos()
. Allows for late overriding of the header videos that are fetched for a given post or term object.
-
$videos
arrayAn associative array of video type strings and the attachment urls for those sizes. Expected format:
array( 'webm' => '', 'mp4' => '' )
-
$obj
objectThe current
WP_Post
orWP_Term
object
array: An associative array of video type strings and the urls for those types
Allows for early overriding of the title (h1) text used for the given post/term object.
-
$title
stringThe post/term title, before theme-specific title logic and custom page header values are applied
-
$obj
objectThe current
WP_Post
orWP_Term
object
string: The title text to use for the post/term object
Allows for late overriding of the title (h1) text used for the given post/term object, after theme logic and custom meta values are applied.
-
$title
stringThe post/term title, after theme-specific title logic and custom page header values are applied
-
$obj
objectThe current
WP_Post
orWP_Term
object
string: The title text to use for the post/term object
Allows for early overriding of the subtitle text used for the given post/term object.
-
$subtitle
stringThe post/term subtitle, before custom page header values are applied
-
$obj
objectThe current
WP_Post
orWP_Term
object
string: The subtitle text to use for the post/term object
Allows for late overriding of the subtitle text used for the given post/term object, after custom meta values are applied.
-
$subtitle
stringThe post/term subtitle, after custom page header values are applied
-
$obj
objectThe current
WP_Post
orWP_Term
object
string: The subtitle text to use for the post/term object