• Resolved laureninspace

    (@laureninspace)


    I am trying to use the Coauthors plugin on the latest version of Expound.

    The solution lies in replacing the <?php the_author(); ?> or similar call with another line of code unique to Coauthors:

    <?php if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else { the_author_posts_link(); } ?>

    The problem is I cannot find where to adjust the way the author’s name shows up above the post anywhere in the theme files. I assumed it’d be in index.html, but even if I flat out delete the part of the loop dealing with author names, the post author’s name still appears as if I hadn’t done anything. Suggestions?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter laureninspace

    (@laureninspace)

    OK, I found it on line 133 of template-tags.php. Can anyone help me rewrite the code to the PHP I need? When I paste in if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else { the_author_posts_link(); } it does not like it.

    // translators: 1: who, 2: when
    	printf( __( '%1$s / %2$s', 'expound' ),
    		sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
    Thread Starter laureninspace

    (@laureninspace)

    If it helps, here is the entire function:

    if ( ! function_exists( 'expound_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function expound_posted_on() {
    	$human_time = expound_human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );
    	$regular_time = get_the_time( get_option( 'date_format' ) );
    
    	$output_time = sprintf( '%s <span style="display:none;">%s</span>', $human_time, $regular_time );
    
    	if ( current_time( 'timestamp' ) > get_the_time( 'U' ) + 60 * 60 * 24 * 14 )
    		$output_time = $regular_time;
    
    	// translators: 1: who, 2: when
    	printf( __( '%1$s / %2$s', 'expound' ),
    		sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
    		sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time )
    	);
    }
    endif;
    
    if ( ! function_exists( 'expound_human_time_diff' ) ) :
    Thread Starter laureninspace

    (@laureninspace)

    Here’s what is not working. You can tell I don’t know PHP:

    printf( __( '%1$s / %2$s', 'expound' ),
    		sprintf( '<a class="author" rel="author" href="%s">%s</a>', if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),

    Be careful modifying a theme, if you update the theme then your changes will be lost. A child theme is a better idea.

    That said, this should work:

    function expound_posted_on() {
    	$human_time = expound_human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );
    	$regular_time = get_the_time( get_option( 'date_format' ) );
    
    	$output_time = sprintf( '%s <span style="display:none;">%s</span>', $human_time, $regular_time );
    
    	if ( current_time( 'timestamp' ) > get_the_time( 'U' ) + 60 * 60 * 24 * 14 )
    		$output_time = $regular_time;
    
    	if ( function_exists( 'coauthors_posts_links' ) ) {
    		coauthors_posts_links();
    	} else {
    		// translators: 1: who, 2: when
    		printf( __( '%1$s / %2$s', 'expound' ),
    			sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
    			sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time )
    		);
    	}
    }
    Thread Starter laureninspace

    (@laureninspace)

    @johnnycardy, I am very grateful for your help. I made sure to build an Expound Child theme for template-tags.php and style.css.

    However, the code still does not seem to be working: https://teenobserver.com/?p=1

    Here is a GitHub Gist of EXACTLY what I have in template-tags: https://gist.github.com/laurenorsini/700a1a8cd85ac4ae0be7

    The child theme might not be picking up the ‘/inc/template_tags.php’ file. I know it was generating an error earlier, but I’m assuming that’s before you decided to create a child theme.

    Try deleting that file from your child theme, and instead, create a functions.php file in your child theme. The add the new expound_posted_on function into it. Don’t include the function_exists call. So all you should have is a style.css and a functions.php which looks like this:

    <?php
    function expound_posted_on() {
    	$human_time = expound_human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );
    	$regular_time = get_the_time( get_option( 'date_format' ) );
    
    	$output_time = sprintf( '%s <span style="display:none;">%s</span>', $human_time, $regular_time );
    
    	if ( current_time( 'timestamp' ) > get_the_time( 'U' ) + 60 * 60 * 24 * 14 )
    		$output_time = $regular_time;
    
    	if ( function_exists( 'coauthors_posts_links' ) ) {
    		coauthors_posts_links();
    	} else {
    		// translators: 1: who, 2: when
    		printf( __( '%1$s / %2$s', 'expound' ),
    			sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
    			sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time )
    		);
    	}
    }
    ?>
    Thread Starter laureninspace

    (@laureninspace)

    You were absolutely right. From now on, I’ll use functions.php if I need to add a new function to a child theme.

    https://teenobserver.com/hello-world/

    I really appreciate your help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Coauthors on Expound’ is closed to new replies.