Site logo

Archived topic

GP Page Headers Standalone Shortcode or PHP Call

5 replies · Started by vr51 on February 8, 2018

Viewing posts 1–6 of 6

I want to assign a page header to all posts within a specific category.

I can set which header to display on the archive page using Categories > Cat. Name > Edit > Set Header but I can't see a GUI way to globally set a specific header to display above any single post assigned to a specific category.

I've looked through the plugin code but can't see a function that tells the theme which header to display and when to display it.

Is there a shortcode I can use or function I can call to display a header within a specific page or post?

I'm looking to do Something similar to (or the shortcode equivalent of):

<?php
if ( ! is_archive() && function_exists('relevant-gp-function') && is_single() && in_category('') ) {
    relevant-gp-function('header-ID'); // Print header with post ID
}
?>

Can it be done?

Thank you, Tom. Looking forward to building with GPP 1.6.

Just merged it with 1.6, so it'll be there.

This will be the usage:

add_filter( 'generate_page_header_id', function( $id ) {
	if ( is_page( 'about' ) ) {
	 	return 17686; // ID of the Page Header to use.
	}
  
  	return $id;
} );

This is why I like GeneratePress!

Will keep a copy of this snippet. Thank you so much.

No problem! :)

This archived topic is closed to new replies.