[Resolved] All Meta In One Single Line

Home Forums Support [Resolved] All Meta In One Single Line

Home Forums Support All Meta In One Single Line

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #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.

    #108022
    Tom
    Lead Developer
    Lead Developer

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

    #108059
    Hftt

    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?

    #108079
    Tom
    Lead Developer
    Lead Developer

    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;
    }
    #108089
    Hftt

    Thank you so so much T!

    “All Is Well”! Long Live GP! πŸ™‚

    #108090
    Tom
    Lead Developer
    Lead Developer

    You’re welcome! πŸ™‚

    #201349
    Elzanne

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

    Thank you.

    #201437
    Tom
    Lead Developer
    Lead Developer

    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? πŸ™‚

    #292881
    Brian

    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

    #292924
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #292941
    Brian

    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

    #292962
    Tom
    Lead Developer
    Lead Developer

    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.

    #292967
    Brian

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

    #293218
    Tom
    Lead Developer
    Lead Developer

    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
    		)
    	);
    }
    #340860
    Eric

    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.

Viewing 15 posts - 1 through 15 (of 24 total)
  • The topic ‘All Meta In One Single Line’ is closed to new replies.