How to Customize or Remove Entry Meta in GeneratePress
Content
Many GeneratePress users want to fine-tune how their post meta information (like categories, tags, author, and date) is displayed. A common goal is to remove these elements from one location, like the post footer, while keeping them in another, or to change their appearance site-wide. This guide covers the most effective methods for customizing entry meta.
Understanding the Problem
By default, GeneratePress displays entry meta in specific locations, such as the header (after the post title) and the footer (after the post content). The footer meta often includes the same categories and tags found in the header, which can lead to unwanted duplication. Users often try to remove an entire meta section with a function, only to find it also removes other crucial elements like post navigation.
Common Solutions
1. Removing Entry Meta from Specific Locations
To remove the entire entry meta section from a specific location, you can use the remove_action() function. This is useful if you want to completely remove all footer meta, for example.
// Remove footer meta on all pages
add_action( 'wp', function() {
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
} );
Important Note: As seen in Thread 1, this approach removes everything hooked to that action, including post navigation. If you only want to remove specific items (like categories and tags) and keep others, you need a more targeted solution.
2. Filtering Specific Meta Items (Recommended)
The best way to selectively show or hide individual meta items is to use the provided filters. You can control which items appear in the header and footer separately.
To modify the header meta items, use the generate_header_entry_meta_items filter:
// Customize header meta items
add_filter( 'generate_header_entry_meta_items', function() {
return array(
'date',
'author',
// 'comments-link', // This item is commented out and will not show
);
} );
To modify the footer meta items, use the generate_footer_entry_meta_items filter. This is perfect for removing categories and tags from the footer to prevent duplication.
// Customize footer meta items on archive pages
add_filter( 'generate_footer_entry_meta_items', function( $items ){
if( is_archive() ) {
return array(
// Return an empty array to show nothing
);
}
return $items; // Return the default items on other pages
} );
3. Conditionally Removing Meta Based on Page Type
You can combine these filters with WordPress conditional tags to target specific pages. For instance, to remove entry meta only from single posts:
// Remove header meta on single posts only
add_action('wp', function() {
if (is_single()) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
});
Or, to remove meta from category and author archive pages:
// Remove header meta on category and author archives
add_action('wp', function() {
if ( is_category() || is_author() ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
});
Styling Entry Meta (Font Size, Color)
To change the appearance of the meta text, such as reducing its font size, you can use CSS. The GeneratePress Customizer includes typography options for the .entry-meta class. Alternatively, you can add custom CSS:
/* Reduce entry meta font size */
.entry-meta {
font-size: 0.85em !important;
}
Important Considerations
- Always add custom PHP code to your child theme's
functions.phpfile or a code snippets plugin to prevent loss during theme updates. - Some advanced layout and styling options, like masonry grids for archives or granular controls within the WordPress Customizer, are features of the GP Premium plugin.
- Clearing your cache after implementing these changes is recommended to see the results immediately.
By using these filters and actions, you can gain precise control over your post meta display, eliminating duplication and creating a cleaner design for your GeneratePress website.
Related Support Threads Support
-
Selectively remove post metahttps://wordpress.org/support/topic/selectively-remove-post-meta/
-
custom excerpt for category postshttps://wordpress.org/support/topic/custom-excerpt-for-category-posts/
-
remove excerpt meta in blog pagehttps://wordpress.org/support/topic/remove-excerpt-meta-in-blog-page/
-
Exclude snippets from individual postshttps://wordpress.org/support/topic/exclude-snippets-from-individual-posts/
-
Remove Entry Meta from Posts in Archiveshttps://wordpress.org/support/topic/remove-entry-meta-from-posts-in-archives/
-
Show #visits and #commentshttps://wordpress.org/support/topic/show-visits-and-comments/
-
Remove pagination in categorieshttps://wordpress.org/support/topic/remove-pagination-in-categories/
-
How to remove specific schema ?https://wordpress.org/support/topic/how-to-remove-specific-schema/
-
Fix posts columns on archive pages and remove empty white space below contenthttps://wordpress.org/support/topic/fix-posts-columns-on-archive-pages-and-remove-empty-white-space-below-content/
-
Excerpthttps://wordpress.org/support/topic/excerpt-78/
-
Remove Whitespace Above Excerpthttps://wordpress.org/support/topic/remove-whitespace-above-excerpt/
-
Entry Meta Texthttps://wordpress.org/support/topic/entry-meta-text/
-
Excerpt Issuehttps://wordpress.org/support/topic/excerpt-issue-7/
-
Removing original blog posts from blog post pagehttps://wordpress.org/support/topic/removing-original-blog-posts-from-blog-post-page/
-
Archive page shows medium size image, change to thumbnail?https://wordpress.org/support/topic/archive-page-shows-medium-size-image-change-to-thumbnail/
-
how can I change the meta robots tags in the theme without using the seo pluginhttps://wordpress.org/support/topic/how-can-i-change-the-meta-robots-tags-in-the-theme-without-using-the-seo-plugin/
-
Remove Entry Meta from Single Postshttps://wordpress.org/support/topic/remove-entry-meta-from-single-posts/
-
filter everything code not workinghttps://wordpress.org/support/topic/filter-everything-code-not-working/
-
Reduce Expert Lengthhttps://wordpress.org/support/topic/reduce-expert-length/
-
excerpt as meta-descriptionhttps://wordpress.org/support/topic/excerpt-as-meta-description/
-
Remove comment icon and link from archiveshttps://wordpress.org/support/topic/remove-comment-icon-and-link-from-archives/
-
Snippet to remove datePublished from Commentshttps://wordpress.org/support/topic/snippet-to-remove-datepublished-from-comments/
-
Remove Archive Title but Keep Category Description or Author Infohttps://wordpress.org/support/topic/remove-archive-title-but-keep-category-description-or-author-info/
-
Nested Commentshttps://wordpress.org/support/topic/nested-comments-10/