Support » Plugin: Co-Authors Plus » Works, but template/ front-end integration very difficult

  • This plug-in works as advertised, but the integration to the front-end (in this case TwentySixteen) was very difficult. I spent hours on it, and ended up getting a consultation from a very skilled PHP developer to make it work. If you use twentysixteen, you’ll save hours with these code changes in the inc/template.php file in twentysixteen after Line 22:

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    function twentysixteen_entry_meta() {
    	if ( 'post' === get_post_type() ) {
    		$author_avatar_size = apply_filters( 'twentysixteen_author_avatar_size', 49 );
    		// printf( '<span class="byline"><span class="author vcard">%1$s<span class="screen-reader-text">%2$s </span> <a href="%3$s">%4$s</a></span></span>',
    		// 	get_avatar( get_the_author_meta( 'user_email' ), $author_avatar_size ),
    		// 	_x( 'Author', 'Used before post author name.', 'twentysixteen' ),
    		// 	esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		// 	get_the_author()
    		// );
    
    		if ( class_exists( 'coauthors_plus' ) ) {
        // Get the Co-Authors for the post
    			$co_authors = get_coauthors();
        // For each Co-Author, echo a wrapper div, their name, and their bio if they have one
    			foreach ( $co_authors as $key => $co_author ) {
    				$co_author_classes = array(
    					'co-author-wrap',
    					'co-author-number-' . ( $key + 1 ),
    					);
    				echo '<div class="' . implode( ' ', $co_author_classes ) . '">';
    				echo get_avatar( $co_author->user_email, '80' );
    				echo '<h3 class="author vcard"><span class="fn"><a>ID, $co_author->user_nicename ).'">'.$co_author->display_name.'</a></span></h3>';
    				echo '</div>';
    			}
    		}
    
    	}
Viewing 1 replies (of 1 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Please don’t recommend that those changes go into the theme files. Instead recommend that a Twenty Sixteen theme user create and activate a child theme and then define that function in the child theme’s functions.php file.

    https://codex.wordpress.org/Child_Themes

    That’s a safer way to do it and the user won’t lose those changes when the theme updates.

Viewing 1 replies (of 1 total)
  • The topic ‘Works, but template/ front-end integration very difficult’ is closed to new replies.