[Resolved] Post Date Meta No Longer Showing in Latest Update

Home Forums Support [Resolved] Post Date Meta No Longer Showing in Latest Update

Home Forums Support Post Date Meta No Longer Showing in Latest Update

  • This topic has 7 replies, 3 voices, and was last updated 1 year ago by Tom.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1485766
    Connor R

    Hi there,

    I use a code snippet (I believe it’s the one below) to show the post updated date in my post meta data.

    Following the latest update of GP, some of my posts are now missing the date (even if I have hit the update button in the WP backend).

    Any help resolving this bug would be greatly appreciated. Thank you!

    add_filter( 'wpsp_date_output', 'tu_wpsp_updated_date_first' );
    function tu_wpsp_updated_date_first() {
    	$time_string = '';
    	
    	$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">
    			%1$s
    		</span>',
    		$time_string
    	);
    
    	return $output;
    	
    }
    #1485783
    Elvin
    Staff
    Customer Support

    Hi,

    Can you link us to the site in question so we could take a closer look?

    You can add the site details on the Private Information text area. Thank you.

    A wise man once said:
    "Have you cleared your cache?"

    #1485787
    Connor R

    Hi Elvin,

    I have put the site in question in the private info area. I have tried clearing the cache as well.

    #1485878
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    The code you shared is for WP Show Posts – it doesn’t have any effect on GeneratePress.

    Are you using a different function for GP, maybe?

    Let us know πŸ™‚

    #1485890
    Connor R

    Anddddd this is why I know when I’m in over my head and head for the forum :)!

    I believe my post meta data snippet is below:

    add_filter( 'generate_footer_entry_meta_items', function() {
        return array(
        );
    } );
    add_filter( 'generate_post_author_output', function() {
        return sprintf( ' <span class="byline">%1$s</span>',
            sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-label">Written by </span><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span><br>',
                esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), 
    	    get_the_author() ) ),
                esc_html( get_the_author() )
            )
        );
    } );
    add_filter( 'generate_inside_post_meta_item_output', function( $output, $item ) {
    	if ( 'categories' === $item ) {
            return ' | ';
        }
        return $output;
    }, 50, 2 );
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
    		'author',
    		'date',
    		'categories',
    
        );
    } );

    I believe showing the updated date (rather than the published date) is done in the CSS using the below:

    .posted-on .updated {
        display: inline-block;
    }
    .posted-on .published {
        display: none;
    }

    Like I said, for some reason this used to work, but after updating GP/GP Premium, it only works on some posts.

    Thanks for the help!

    #1487064
    Tom
    Lead Developer
    Lead Developer

    Instead of this:

    .posted-on .published {
        display: none;
    }

    Do this:

    .posted-on .updated + .published {
        display: none;
    }

    Let me know πŸ™‚

    #1487403
    Connor R

    That did the trick. Thank you, Tom!

    #1488907
    Tom
    Lead Developer
    Lead Developer
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.