Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Date before H1

  • Hi,

    is it possible to edit the following code so that it appears before the H1 of each post?

    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    	if ( is_single() ) {
    		$time_string = '<span class="date-label">veröffentlicht </span><span><time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s </time></span>';
    
    		$updated_time = get_the_modified_time( 'U' );
    		$published_time = get_the_time( 'U' ) + 86400;
    
    		if ( $updated_time > $published_time ) {
    			$time_string .= '<span class="date-label"> - aktualisiert </span><span><time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s </time></span>';
    		}
    
    		$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 $time_string;
    }, 10, 2 );

    Thank you very much!

    Greetings Kathrin

  • Hi Kathrin,

    A different code or solution would be needed to move the date. The code or solution would depend on your Posts’ structure.

    For reference, can you share a link to a Post on your site?

  • Than I will close that topic again, because than we have to solve it in connection with the featured image 🙂

    Thank you very much!

    Greetings Kathrin

  • You’re welcome! Yes, this seems related to your other topic as well. We can address it there.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.