[Resolved] Disabling linking to author's posts

Home Forums Support Disabling linking to author's posts

Viewing 4 posts - 31 through 34 (of 34 total)
  • Author
    Posts
  • #873654
    Ericka

    I remove the code and try adding the css you told me. But then my posts showed the last update and the published date together :S. Of course none of them have links (which is cool because that’s what I wanted), but how can I remove the published date?

    #873890
    Tom
    Lead Developer
    Lead Developer

    Try this as your function:

    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>';
    
    	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    		$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> ', // WPCS: XSS ok, sanitization ok.
    		$time_string
    	);
    }, 10, 2 );

    It should handle both things for you.

    #873893
    Ericka

    Thank you so much!!! It works perfect!!

    #873898
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 31 through 34 (of 34 total)
  • You must be logged in to reply to this topic.