- This topic has 23 replies, 2 voices, and was last updated 4 years, 5 months ago by
Tom.
-
AuthorPosts
-
May 14, 2015 at 11:10 pm #108019
Hftt
Hi
I’d like to display all meta in one single line under title. Like –
POST TITLE
(Date) by (Author) – (Categories) (Tags) (Comment Link)Is it possible to do that?
Thanks T.
May 14, 2015 at 11:15 pm #108022Tom
Lead DeveloperLead DeveloperHad someone ask this exact thing a few days ago actually! π
This function should do the trick: https://gist.github.com/generatepress/a07fbf6ae38a490c1d6e
How to add PHP: http://generatepress.com/knowledgebase/adding-php-functions/
May 15, 2015 at 6:45 am #108059Hftt
Thanks much. I add the function and it works.
1. But those meta – (Categories) (Tags) (Comment Link) still display at post footer area.
2. Is it possible to display all meta in one single line?
May 15, 2015 at 8:26 am #108079Tom
Lead DeveloperLead DeveloperAh, sorry about that.
Updated the function: https://gist.github.com/generatepress/a07fbf6ae38a490c1d6e
This CSS is necessary as well:
footer.entry-meta { display: none; } .cat-links, .tags-links, .comments-link { display: inline-block; margin-left: 10px; }
May 15, 2015 at 8:42 am #108089Hftt
Thank you so so much T!
“All Is Well”! Long Live GP! π
May 15, 2015 at 8:43 am #108090Tom
Lead DeveloperLead DeveloperYou’re welcome! π
June 12, 2016 at 12:52 pm #201349Elzanne
How can I also display the author avatar inline with the entry meta below the post title?
Thank you.
June 13, 2016 at 12:33 am #201437Tom
Lead DeveloperLead DeveloperInteresting – I’ll have to look into that.
Any chance you can start your own topic and let me know where you’d like it? Before the other meta info or after? π
March 16, 2017 at 9:43 am #292881Brian
I also want to display the avatar on the meta line like Elzanne wanted too. Did you ever give a fix for this? I searched the forum but could not find anything.
I also want to have all the meta on the one line. Is your code still valid?
https://gist.github.com/generatepress/a07fbf6ae38a490c1d6eThanks
March 16, 2017 at 10:11 am #292924Tom
Lead DeveloperLead DeveloperAny chance you can show me an example of what you’re wanting to do exactly? The latest version of GP allows for a lot more possibilities when it comes to the meta π
March 16, 2017 at 10:33 am #292941Brian
Sure. I am switching to your theme for this site: https://sluggerotoole.com
One this site we used the woothemes canvas. By the way canvas has not been actively updated in years so you should target some of your marketing towards canvas users as your theme is the natural successor in my view.
Anyway if you look at any of the posts on that site, you see how in the meta line we have time, comment count, and posts views (we get this from jetpack stats)
https://goo.gl/9b9d3zIn canvas we used filters to achieve this:
https://goo.gl/GbmWSZSo basically I am trying to recreate the meta data line in generate press.
The only thing i would live to add to the meta line is the author avatar image.
Thanks
March 16, 2017 at 10:58 am #292962Tom
Lead DeveloperLead DeveloperWe have filters as well, but they’re a little more advanced than that: https://docs.generatepress.com/article/generate_post_author_output/
The issue there is, the WP function that displays the number of comments is very old, and can’t be used inside filters (I know, brutal).
So, your best bet may be to use the function you linked to originally, as that will allow you to include the comments link inside the same line.
March 16, 2017 at 11:08 am #292967Brian
Ok. What about the simpler stuff like adding the time to the meta line?
March 16, 2017 at 9:57 pm #293218Tom
Lead DeveloperLead DeveloperThat’s much easier thanks to this filter: https://docs.generatepress.com/article/generate_post_date_output/
I assume you’d want it to be in this kind of format: March 16, 2017 at 9:00PM?
add_filter( 'generate_post_date_output', 'tu_add_time_to_date' ); function tu_add_time_to_date() { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); // If our date is enabled, show it printf( '<span class="posted-on">%1$s</span>', sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a> at %2$s', esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ) ); }
June 28, 2017 at 10:54 am #340860Eric
Ah, sorry about that.
Updated the function: https://gist.github.com/generatepress/a07fbf6ae38a490c1d6e
This CSS is necessary as well:
footer.entry-meta {
display: none;
}.cat-links, .tags-links, .comments-link {
display: inline-block;
margin-left: 10px;
}What changes would need to be made if I wanted to remove the tags from that top single line and keep them on the bottom? I use quite a few tags for my content and it looks too cluttered at the top.
-
AuthorPosts
- The topic ‘All Meta In One Single Line’ is closed to new replies.