- This topic has 5 replies, 3 voices, and was last updated 3 years, 9 months ago by David.
-
AuthorPosts
-
June 27, 2020 at 9:10 am #1343774Ales
Hi,
I want to have author name, publish date and category(ies) on the top of the post together in one line. For example how it is here:
I found this code, which I have as a snippet:
add_filter( 'generate_category_list_output','lh_remove_singlecategories' ); function lh_remove_singlecategories( $categories ) { if ( is_single() ) { return ''; } return $categories; } add_action( 'generate_before_entry_title','lh_single_cats_above_title' ); function lh_single_cats_above_title() { if ( is_single() ) { $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) ); if ( $categories_list ) { 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 ); } } }
But it does this:
Also there is no space between September 8, 2018 and by Alex because I removed the link from the date with this code:
add_filter( 'generate_post_date_output', function( $output, $time_string ) { printf( '<span class="posted-on">%s</span>', $time_string ); }, 10, 2 );
And this is exactly the same on homepage/category pages with list of posts.
I would really appreciate if you can help me to style this in the way I showed in the example.
Thanks a lot!
Have a nice day,
AlešJune 27, 2020 at 3:44 pm #1344023TomLead DeveloperLead DeveloperHi there,
I would do something like this, instead:
add_filter( 'generate_header_entry_meta_items', function( $items ) { return array( 'author', 'date', 'categories', ); } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { return array_diff( $items, [ 'categories' ] ); } );
As for the space, try the updated code here: https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date
Let me know 🙂
June 27, 2020 at 5:36 pm #1344076AlesHi Tom,
Thanks a lot for your help! It works now perfectly.
Can I have one more request for minor tweaks?
1. There is not that category (folder) icon next to the categories.
2. Author, date and categories are very close to each other. Is there any way how to do some margin?
3. On the homepage (or category page) there is still spacing for missing list of categories on the bottom of each post, altough the categories are now correctly under the title. It doesn’t look very well, it’s too much white space. Can I somehow reduce this space?
Thanks a lot!
AlešJune 28, 2020 at 5:49 am #1344344DavidStaffCustomer SupportHi there,
try this CSS:
/* Display Cat Icon */ .entry-header .gp-icon.icon-categories { display: inline; } /* Entry meta item spacing */ .entry-header .entry-meta > a, .entry-header .entry-meta .posted-on { margin-right: 0.75em; } /* Remove additional footer space from archive */ body:not(.single) footer.entry-meta { margin-top: 0; }
July 1, 2020 at 12:44 am #1347801AlesHi David,
Thanks a lot, this works like a charm!
Have a nice day,
ByeJuly 1, 2020 at 4:19 am #1347980DavidStaffCustomer SupportGlad to be of help
-
AuthorPosts
- You must be logged in to reply to this topic.