Archived topic
Setting Entry Meta Style Only Show in Single
1 reply · Started by Randy on May 4, 2021
I try to use entry meta style from here https://docs.generatepress.com/article/entry-meta-style/
I used example 2. But it is show on hompepage even I disable author on single.
Can you help me to change the code to show in single only?
add_filter( 'generate_header_entry_meta_items', '__return_empty_array' );
add_action( 'generate_after_entry_title', 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">
<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
} );
.entry-meta-container {
display: flex;
align-items: center;
}
.entry-meta-gravatar {
margin-right: 10px;
}
.entry-meta-gravatar img {
width: 50px;
border-radius: 50%;
}
.entry-meta-info {
display: block;
}
Hi Randy,
I would recommend to use the new feature of GP Premium 2.0: dynamic content.
With the new feature, you can build your own entry meta style without using code, and it's the way to go from now on :)
Here's the documentation of how to build post meta:
https://docs.generatepress.com/article/block-element-post-meta-template/
Please be noted, Generateblocks plugin is required in order to use the new feature.