• I’ve just changed to Twenty Fifteen after ten years on an old WP template, but I can’t get the author’s name to show under each post. The date, ‘Leave a Comment’ and ‘Edit’ (when I’m logged in) show fine, but nothing else. I haven’t played with code for many years and it’s moved on a bit so I’m a bit lost as to where to look. There’s plenty of posts on how to remove this metadata, but I can’t find any that are clear on how to retrieve it.
    Any help would be appreciated.
    My site is https://sparrowchat.com
    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I see it. On the bottom of https://sparrowchat.com/r-i-p-geoffrey-jones-of-bridgend-south-wales/ I see

    Posted on August 10, 2016 Author R J Adams

    the author is not output into the index and archive pages, unless the blog has more than one author.
    it is output to the single post in any case;

    done via this section in /inc/template-tags.php in the function twentyfifteen_entry_meta():

    if ( 'post' == get_post_type() ) {
    		if ( is_singular() || is_multi_author() ) {
    			printf( '<span class="byline"><span class="author vcard"><span class="screen-reader-text">%1$s </span><a class="url fn n" href="%2$s">%3$s</a></span></span>',
    				_x( 'Author', 'Used before post author name.', 'twentyfifteen' ),
    				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    				get_the_author()
    			);
    		}

    as the function is pluggable, you can re-code it in functions.php of a child theme and change the conditional section.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    install the plugin “show current template”. It will let you know which templates are rending the content you’re looking at. You’ll need to add the right tags in them.

    If you are working with twentyfifteen itself, you should first create a child theme.

    Thread Starter capelyddol

    (@capelyddol)

    WOW! I feel like I’m back in kindergarten again. So much has changed in ten years. I really should have kept up more. I’ve installed “show current template” but not sure how it helps me. ‘Index.php’ seems to be the template for everything on the ‘front’ page but I haven’t a clue what to do with that information right now.
    I need to do some swotting. If one of you guys could rewrite the code supplied by Michael to enable me to show the author name on all posts, that might give me a head start. I’m using a twenty fifteen child them but the only thing in it right now is a bit of CSS to alter font sizes.
    I appreciate your efforts. Thanks a lot.

    this is the code of the edited function, which should go into functions.php of a child theme of Twenty Fifteen:

    function twentyfifteen_entry_meta() {
    	if ( is_sticky() && is_home() && ! is_paged() ) {
    		printf( '<span class="sticky-post">%s</span>', __( 'Featured', 'twentyfifteen' ) );
    	}
    
    	$format = get_post_format();
    	if ( current_theme_supports( 'post-formats', $format ) ) {
    		printf( '<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>',
    			sprintf( '<span class="screen-reader-text">%s </span>', _x( 'Format', 'Used before post format.', 'twentyfifteen' ) ),
    			esc_url( get_post_format_link( $format ) ),
    			get_post_format_string( $format )
    		);
    	}
    
    	if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
    		$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    
    		if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    			$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
    		}
    
    		$time_string = sprintf( $time_string,
    			esc_attr( get_the_date( 'c' ) ),
    			get_the_date(),
    			esc_attr( get_the_modified_date( 'c' ) ),
    			get_the_modified_date()
    		);
    
    		printf( '<span class="posted-on"><span class="screen-reader-text">%1$s </span><a href="%2$s" rel="bookmark">%3$s</a></span>',
    			_x( 'Posted on', 'Used before publish date.', 'twentyfifteen' ),
    			esc_url( get_permalink() ),
    			$time_string
    		);
    	}
    
    	if ( 'post' == get_post_type() ) {
    		//if ( is_singular() || is_multi_author() ) { //commented to show author in all cases
    			printf( '<span class="byline"><span class="author vcard"><span class="screen-reader-text">%1$s </span><a class="url fn n" href="%2$s">%3$s</a></span></span>',
    				_x( 'Author', 'Used before post author name.', 'twentyfifteen' ),
    				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    				get_the_author()
    			);
    		//} //commented to show author in all cases
    
    		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
    		if ( $categories_list && twentyfifteen_categorized_blog() ) {
    			printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    				_x( 'Categories', 'Used before category names.', 'twentyfifteen' ),
    				$categories_list
    			);
    		}
    
    		$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) );
    		if ( $tags_list ) {
    			printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    				_x( 'Tags', 'Used before tag names.', 'twentyfifteen' ),
    				$tags_list
    			);
    		}
    	}
    
    	if ( is_attachment() && wp_attachment_is_image() ) {
    		// Retrieve attachment metadata.
    		$metadata = wp_get_attachment_metadata();
    
    		printf( '<span class="full-size-link"><span class="screen-reader-text">%1$s </span><a href="%2$s">%3$s &times; %4$s</a></span>',
    			_x( 'Full size', 'Used before full size attachment link.', 'twentyfifteen' ),
    			esc_url( wp_get_attachment_url() ),
    			$metadata['width'],
    			$metadata['height']
    		);
    	}
    
    	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
    		echo '<span class="comments-link">';
    		/* translators: %s: post title */
    		comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentyfifteen' ), get_the_title() ) );
    		echo '</span>';
    	}
    }
    Thread Starter capelyddol

    (@capelyddol)

    Thanks, Michael, that works a treat. I really appreciate your efforts, it look a lot of work. I will run comparisons with your code and the original. Hopefully, it will provide some insight into how you did it.
    Thanks again.

    I can not get it to work. I have installed the co-authors plus plugin on my child theme twentyfifteen but nothing is showing up. I have changed the funtions.php and the template-tags.php but no authors are showing.

    Can you help me?

    • This reply was modified 7 years, 10 months ago by Florencia.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Author name not appearing under posts in twenty fifteen’ is closed to new replies.