Archived topic
Flip Menu and Page Header
6 replies · Started by Bryn on October 12, 2015
Is it possible to place the page header above the menu? I just want to reverse the two.
ALSO, is it possible to assign a custom page header for category pages?
Hi there,
Give this PHP a try:
add_action('after_setup_theme','generate_change_nav_position');
function generate_change_nav_position()
{
remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
add_action( 'generate_after_header', 'generate_add_navigation_after_header', 29 );
}
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
As for adding a page header to the category pages:
You can use WordPress conditionals in the hooks to tell content to show up on certain pages. For example, if you want your page header to be displayed below your header on category pages, you would add something like this to your "After Header" hook in "GP Hooks":
https://codex.wordpress.org/Function_Reference/is_category
<?php if ( is_category() ) : ?>
<div class="page-header-image grid-container grid-parent generate-page-header">
<img src="URL TO YOUR CATEGORY HEADER IMAGE" alt="" itemprop="image">
</div>
<?php endif; ?>
For specific categories, you would do something like this using the category name:
<?php if ( is_category( 'Category Name' ) ) : ?>
<div class="page-header-image grid-container grid-parent generate-page-header">
<img src="URL TO YOUR CATEGORY HEADER IMAGE" alt="" itemprop="image">
</div>
<?php endif; ?>
Hope this helps :)
The PHP to change the header/menu positions isn't working.
As for the category images, I simply want to set a custom page header for the page categories. Like here: http://julesknowlton.com/category/short-stories-and-poetry/
How did you add the PHP? I just tested it and it worked as it should.
That page is returning a 404.
There's no real way to set a page header for category pages, as they don't have static pages that you can edit from the back-end - WordPress creates them for you.
The best way is to use GP Hooks with the code I mentioned above.
Let me know :)
Thanks! The header/menu flip worked when I created a plugin.
However the PHP for the category image is returning an error:
Parse error: syntax error, unexpected '<' in /home3/tlmpksuz/public_html/wp-content/plugins/category-image/category-image.php on line 12
<?php if ( is_category( 'Short Stories and Poetry' ) ) : ?>
<?php endif; ?>
In the hook where you placed the code make sure the "Execute PHP" option is checked.
Yea, that code should be added to GP Hooks in the "After Header" hook - not that category image plugin.