Archived topic
Schema markup for datePublished and dateModified
22 replies · Started by Nacho on January 16, 2019
Hello Tom,
I was wondering how could I set the markup for datePublished and dateModified.
In the URL below, if you test it with the tool https://search.google.com/structured-data/testing-tool?hl=es# you´ll see that there is no markup.
Thanks a lot for your help.
Hi there,
It looks like you have the post date option turned off in Customize > Layout > Blog.
If you turn that back on, you should be good to go.
Hello Tom,
I don´t want to show it to the front end user, just so crawlers can see it. Also activating that feature you just see the published date not the updated date.
How can I get this?
Thanks a lot.
Crawlers actually won't use it unless it's visible to the user, as far as I understand.
However, I suppose you could enable it in the Customizer, then hide it with CSS:
.posted-on {
display: none;
}
Hello Tom,
Actually it doesn't matter if you show up in your page for crawlers to crawl it.
Anyway, how can I get the last updated/modified date to show?
Thanks a lot.
This should help:
https://docs.generatepress.com/article/show-the-updated-post-date/
If you want the markup to be in your source code, enable the date in Customize > Layout > Blog.
Then use the CSS I provided above to hide it from users.
If you want to display the updated date to your users, the link Leo shared above is the way to go :)
Hello Tom and Leo,
That worked perfectly.
Also, how do I remove the date links? and also how do I remove the marging on posts that I´ve hidden the date like in the URL that I´ve just updated for this topic?
Basically I want to remove the links of the dates and remove the metadata of specific categories (but I´ve seen that with the code below there is still a margin).
.category-categoryXXX .entry-meta {
display: none;
}
Thanks a lot.
This should help: https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date
That CSS should remove the margin. Is there a specific page where I can see it?
Hello Tom,
Thanks for the date link, I´m gonna try right now.
About the CSS, yes you can see it in the page that I´ve attached to this topic.
Thanks.
Hello Tom,
I´ve just tested the link code https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date, but it freezes wordpress and does not work actually.
I´ve used this code:
add_filter( 'generate_post_date_output','tu_remove_date_link', 10, 2 );
function tu_remove_date_link( $output, $time_string ) {
printf( '<span class="posted-on">%s</span>',
$time_string
);
}
Is that code ok?
Thanks a lot.
Looks good to me - how are you adding it?
Hello Tom,
I´m adding it with the "Code Snippets" plugin but whenever I click the save button Wordpress gets blocked.
I´ve tested in other sites and it happens the same.
Let me know what I can do.
Thanks a lot.
Hello Tom,
Weird thing: Wordpress freezes when adding saving the code, then you refresh the page, Wordpress comes back and the code actually is working right now.
Well, if it works :) I don´t if you want me to digg in a little bit.
Thanks a lot.
I've heard that Code Snippets has been doing that lately - hopefully they get it fixed soon.
Glad the code worked :)