Archived topic
Post title and meta above sidebar
21 replies · Started by George on February 23, 2021
Is there a way to achieve that without using a header element? I don't have great control over the title paddings using the header element (I also use a custom width for the single post page) plus I don't want to lose the customizations I did on the meta.
Hi George,
Would this help?
https://generatepress.com/forums/topic/move-entry-header-above-content-and-sidebar/#post-684692
Yeah, I've tried that, all it does is duplicates the title but doesn't take it out of the container. And I also have the post meta.
Does this one work better?
https://wordpress.org/support/topic/title-above-content-and-sidebar/#post-13540076
It would be much easier with GPP 2.0 ;)
Ok, that worked exactly like the header element. I would have to adjust the width with CSS. But what about the post meta underneath?
I am using this example for the meta:
https://docs.generatepress.com/article/entry-meta-style/#example-2
Does it work if you replace generate_after_entry_title with generate_after_header in the entry meta code?
Just switching a hook.
generate_after_header is the one used. generate_after_entry_title just swaps meta and title position but keeps it inside the container.
Oh, you mean the post meta hook maybe? Switching the hook puts the meta over the title and loses the styling.
I just tried this function:
add_action( 'wp', function() {
if ( is_page() || is_single() ) {
add_filter( 'generate_show_title', '__return_false' );
}
} );
add_action( 'generate_after_header', function() {
if ( is_page() || is_single() ) :
?>
<div class="header-entry-title grid-container grid-parent">
<h1 class="entry-title"><?php the_title(); ?></h1>
</div>
<div class="grid-container grid-parent entry-meta">
<?php generate_posted_on(); ?>
</div>
<?php
endif;
} );
add_filter( 'generate_header_entry_meta_items', '__return_empty_array' );
add_action( 'generate_after_header', function() {
$header_post_types = apply_filters(
'generate_entry_meta_post_types',
array(
'post',
)
);
if ( ! in_array( get_post_type(), $header_post_types ) ) {
return;
}
?>
<div class="entry-meta entry-meta-container grid-container">
<div class="entry-meta-gravatar">
<?php echo get_avatar( get_the_author_meta( 'ID' ) ); ?>
</div>
<div class="entry-meta-info">
<div class="entry-meta-author">
<?php generate_do_post_meta_item( 'author' ); ?> in <?php generate_do_post_meta_item( 'categories' ); ?>
</div>
<div class="entry-meta-date">
<?php generate_do_post_meta_item( 'date' ); ?>
</div>
</div>
</div>
<?php
} );
And this is the result:
https://www.screencast.com/t/VShYxXqJSH
Looks like it's just missing the CSS styling.
If this still doesn't work, any chance we can revisit the issue once GP 2.0 is live?
We really can't be providing a custom/outdated solution like this at this point.
Thanks for your understanding.
Ok, better, it lost the author gravatar (displays default one) and author name, though.
Ok, sure. This is not outdated solution, though, this is how GP is right now! GP 2.0 is still alpha.
it lost the author gravatar (displays default one) and author name, though
Not sure if I understand. Is this the result you are getting?
https://www.screencast.com/t/VShYxXqJSH
Could we please revisit this issue once we can use the GP 2.0? We put in a lot of work for the dynamic content to avoid providing custom solution like this.
Thanks for your understanding.
I have to say, it's the only time I am not happy with support. I understand what you are saying but I think you should have provided support for existing features. The upcoming version is still alpha. I have a client handover in two days.
You know how much I respect you and all the GP crew but in this instance, I think it was wrong to refuse support like this. I hope you take it as constructive feedback.
So what isn't working for you?
I added my code above with the CSS from the example doc page and this is the result:
https://www.screencast.com/t/z1rORY4YMIP
Is this not what you are getting?
I am adding the same code as you do but I get the result attached. Basically, I lose the normal avatar image (default icon is displayed) and the Author name.