- This topic has 11 replies, 2 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
March 13, 2019 at 12:54 am #837349
Luong
I want to remove dataPublished markup from the posts so Google can only read dateModified.
Please help me!
GeneratePress 2.2.2March 13, 2019 at 9:04 am #837903Tom
Lead DeveloperLead DeveloperHi there,
Give this function a try:
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 );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 15, 2019 at 10:33 pm #840360Luong
Hi,
I added the code in the functions.php of the child theme. But when I checked with Google’s structured data testing tool, it still showed the datePublished.March 16, 2019 at 8:39 am #840779Tom
Lead DeveloperLead DeveloperCan you link me to page you’re testing?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 17, 2019 at 6:12 pm #841752Luong
here’s the link to one of the posts:
March 18, 2019 at 9:22 am #842358Tom
Lead DeveloperLead DeveloperThe code I mentioned above doesn’t seem to be activated. If it is, you might have another conflicting function. Anything else targeting the
generate_post_date_output
filter?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 18, 2019 at 8:08 pm #842832Luong
Hi, here’s what the functions.php file includes
March 19, 2019 at 8:46 am #843480Tom
Lead DeveloperLead DeveloperHmm, your HTML isn’t matching what our function should be outputting.
Any other functions anywhere? In the Code Snippets plugin maybe?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 19, 2019 at 4:56 pm #843924Luong
No, I don’t have Code Snippets installed. But I install a plugin called Schema. Does it affect things there?
March 19, 2019 at 5:25 pm #843947Tom
Lead DeveloperLead DeveloperNo, it shouldn’t. I just tried the code on my test site and it is indeed working.
Can you try adding the function using the Code Snippets plugin just to test?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 21, 2019 at 12:49 am #845194Luong
I tried using the plugin, Still not work. Anyway, thank you very much for the effort ๐
March 21, 2019 at 8:33 am #845746Tom
Lead DeveloperLead DeveloperHmm, something must be conflicting.
Any chance you can send me temporary admin login details so I can take a closer look?: https://generatepress.com/contact
If so, be sure to mention this topic.
Thanks!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.