Site logo

Archived topic

All Meta In One Single Line

23 replies · Started by Hftt on May 14, 2015

Viewing posts 1–15 of 24

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.

Thanks much. I add the function and it works.

http://prntscr.com/75hyqg

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?

Thank you so so much T!

"All Is Well"! Long Live GP! :)

You're welcome! :)

How can I also display the author avatar inline with the entry meta below the post title?

Thank you.

Interesting - 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? :)

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/a07fbf6ae38a490c1d6e

Thanks

Any 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 :)

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/9b9d3z

In canvas we used filters to achieve this:
https://goo.gl/GbmWSZ

So 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

We 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.

Ok. What about the simpler stuff like adding the time to the meta line?

That'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
		)
	);
}

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.

This archived topic is closed to new replies.