Archived topic
How to move date post to the header
20 replies · Started by Ivan Cazorla on August 31, 2016
Hey Tom,
Theres any way to move the post's date and category to the header, below the title? I show you a photo too:
http://es.tinypic.com/r/2lqj42/9
Thanks,
Ivan!
How are you getting the title up there?
Hey, I used the Page Header function and I disabled the "content title" with the Disable Elements GeneratePress Premium.
So did you manually enter the title into the Page Header content?
Exactly!! What should I do now?
Well that way you would have to manually enter the meta content into the Page Header.
Or you could do it automatically:
add_filter( 'generate_show_title', 'generate_hide_single_title' );
function generate_hide_single_title()
{
if ( is_single() )
return false;
return true;
}
add_action( 'after_setup_theme','generate_remove_posted_on' );
function generate_remove_posted_on()
{
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
add_action('generate_after_header','generate_add_post_title_below_header');
function generate_add_post_title_below_header()
{
// Add the single post IDs we want to target to the array below, separated by commas
if ( is_single() ) : ?>
<div class="page-header-content generate-page-header generate-content-header" style="background-image:url( <?php the_post_thumbnail_url(); ?> );background-size:cover;">
<div class="inside-page-header-container inside-content-header grid-container grid-parent">
<header class="entry-header">
<?php the_title( '<h1 class="entry-title" itemprop="headline">', '</h1>' ); ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
</div>
</div>
<?php endif;
}
Should get you started :)
Thank you for the code but, where do I need to place this code?
Thanks,
Ivan
This should help: https://generatepress.com/knowledgebase/adding-php-functions/
thanks :)
It worked, but... Now I have two page headers. How can I delete the first one?
http://es.tinypic.com/r/2nvw0g7/9
Thanks,
Ivan
Remove it on the page itself (using the metabox).
You'll also need to style the new one with CSS.
If that's too much, the only other option is manually adding the title and post meta into the page header metabox.
If I do that now both Page Headers disapear :/ What am I doing wrong?
http://es.tinypic.com/r/vp97r6/9
Thanks,
Ivan
Instead of disabling it, just remove the content from the content textbox in the Page Header metabox.
I also tried that, but now I get a big image of the post, and my custom page header code below (and without the post image).
http://es.tinypic.com/r/fci51s/9
Thanks,
Ivan
You'll want to remove the image like this:
.page-header-image-single {
display: none;
}