Site logo

Archived topic

author not displaying on single post page

11 replies · Started by Linda on October 30, 2020

Viewing posts 1–12 of 12

I have searched the forum and reviewed similar questions but I can't seem to figure out why the author is not showing on the single post page. On my front page I am using WP Show Posts and the author appears there, but when you click to see main post, the author is not there. Any ideas appreciated, thanks.

Looks like you are using some custom functions for the entry meta.

Can you share the code here?

Let me know :)

Using 2 snippets, 1 of 2 here

//https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date
//This code will remove the published date HTML if an updated date exists.

add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';

    $updated_time = get_the_modified_time( 'U' );
    $published_time = get_the_time( 'U' ) + 86400;

    if ( $updated_time > $published_time ) {
        $time_string = '<time class="entry-date updated-date" 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() )
    );

    return sprintf( '<span class="posted-on">%s</span> ',
        $time_string
    );
}, 10, 2 );

Snippet 2 of 2 here:

add_filter( 'wpsp_date_output', 'tu_wpsp_updated_date_first' );
function tu_wpsp_updated_date_first() {
	$time_string = '';
	
	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$time_string .= '<time class="wp-show-posts-updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
	}
	
	$time_string .= '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$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
	$output = sprintf(
		'<span class="wp-show-posts-posted-on wp-show-posts-meta">
			<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>
		</span>',
		esc_url( get_permalink() ),
		esc_attr( get_the_time() ),
		$time_string
	);

	return $output;
	
}

Also sending login info to my (sloppy) staging site

Can you remove the first function first?

Let me know :)

Removing first one, then both of the snippets caused no change in the single post page (after clicking on the read more)

Can you first clear and disable all the caching plugins you are using?

I did try removing the caching plugin, but it had no effect.
However, I did get it working after much trial and error, but don't ask me why it now works, maybe because it's Halloween? I have this plugin installed, https://wordpress.org/plugins/wp-last-modified-info/. I made no changes except to save (again) the settings in that plugin. Now the author name shows up. It's a mystery, but at least it's working. Thanks so much for helping me troubleshoot!

No problem :)

This archived topic is closed to new replies.