Archived topic
Customizing display post meta data
9 replies · Started by Rovanov on September 23, 2019
Hi Generate!
Is it possible to place the” Display post categories " at the top of the single post directly under post author / post date, and not at the end of the post?
They're bad to find there, even under the related post with me.
https://wakkermens.info/van-bolsjewisme-naar-bureaucratie/
Thank you for answering,
greetings
Rovanov
Hi there,
you can use the Post Meta filter to include them in the Entry Meta:
https://docs.generatepress.com/article/generate_header_entry_meta_items/
You filter would look something like this:
add_filter( 'generate_header_entry_meta_items', function( $items ) {
if ( is_single() ) {
$items = array(
'date',
'author',
'categories',
);
} return $items;
} );
If that works we can assist with some CSS to display the categories below the date and author.
Thank you for the quick answer!
Sorry, I'm a beginner.
In what file should I put this in?
Don't worry, I can try it on my local host. :-)
Thanks,
Rovanov
Hi there,
That code can be added using one of these methods: https://docs.generatepress.com/article/adding-php/
Thank you!
Glad we could be of help
Hello support team!
Okay, that works great, but this way is not very beautiful.
Now I want more. :-)
(Of course, I am willing to pay for such a personal adjustment.)
How do I get the categories with map-icon above the date and author in a single post?
Thanks & greetings!
Rovanov
Hi there,
so instead of the code provided above, add this:
add_filter( 'generate_category_list_output','lh_remove_categories' );
function lh_remove_categories( $categories ) {
if ( is_single() ) {
return '';
}
}
add_action( 'generate_after_entry_title','lh_single_cats_above_title' );
function lh_single_cats_above_title() {
$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
if ( $categories_list && is_single() ) {
printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Categories', 'Used before category names.', 'generatepress' ),
$categories_list
);
}
}
Then add this CSS to include a dashicon before it:
.entry-meta.cat-links:before {
content: "\f231";
font-family: "dashicons";
display: inline;
}
Yes!!!!!!!!
Great, wonderful, genius!
I love you!
When are we gonna have a beer? (Amsterdam?)
I've change the following.:
content: "\f231"; to: content: "\f07b";
and
font-family: "dashicons" to: font-family: "GeneratePress";
Thank you very much!
Glad to be of help :)
Feel free to buy some coffees:
https://generatepress.com/ongoing-development/