- This topic has 5 replies, 2 voices, and was last updated 8 months, 1 week ago by
David.
-
AuthorPosts
-
June 20, 2015 at 8:23 pm #115829
Steven Porters
Hi Tom,
How can I remove the timestamp that appears in the code for posts that makes it so a time is listed in Google SERPs?
June 20, 2015 at 11:38 pm #115833Tom
Lead DeveloperLead DeveloperHi there,
This function should do the trick: https://gist.github.com/generatepress/9986c15bbffafa0cc7e1
Adding PHP: http://generatepress.com/knowledgebase/adding-php-functions/
January 24, 2023 at 11:01 pm #2508102Vijaykumar
Hi Tom
The code you mentioned here https://gist.github.com/generatepress/9986c15bbffafa0cc7e1
does not work for PHP 8. It gives undefined $time_string error.
Do you have an updated code for the same?We have following code to SHOW only post/page updated date and HIDE published date but it’s not working on PHP 8 due to above error. Any idea what needs to be changed to make this work?
if ( ! function_exists( ‘generate_posted_on’ ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function generate_posted_on()
{
$date = apply_filters( ‘generate_post_date’, true );
$author = apply_filters( ‘generate_post_author’, true );
//if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) )
$time_string .= ‘<time class=”updated” 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() )
);// If our date is enabled, show it
if ( $date ) :
printf( ‘<span style=”float: left; margin-right: 3px;”>Last Updated:</span><span class=”posted-on”>%1$s</span>’,
sprintf( ‘%3$s‘,
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
)
);
endif;// If our author is enabled, show it
if ( $author ) :
printf( ‘ <span class=”byline”>%1$s</span>’,
sprintf( ‘<span class=”author vcard” itemtype=”http://schema.org/Person” itemscope=”itemscope” itemprop=”author”>%1$s <span class=”author-name” itemprop=”name”>%4$s</span></span>’,
__( ‘by’,’generatepress’),
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() )
)
);
endif;}
endif;January 25, 2023 at 2:42 am #2508281David
StaffCustomer SupportHi there,
this topic is realllllly old… and it should not be necessary.
Are you wanting to just show the relevant date? or do you need to strip the timestamp from the HTML ?
If its the former then this filter will do that:https://docs.generatepress.com/article/generate_post_date_show_updated_only/
Let me know
January 25, 2023 at 4:01 am #2508383Vijaykumar
Hi David
We have used the code that was shown on this script to hide published date from live pages and posts.
I am discussing this same with you on this thread as well https://generatepress.com/forums/topic/unable-to-show-last-updated-date-on-pages/#post-2508302January 25, 2023 at 4:10 am #2508393David
StaffCustomer SupportReplied to your other topic.
-
AuthorPosts
- You must be logged in to reply to this topic.