Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[last_modified] not in <time> format #2

Open
schasoli opened this issue Apr 2, 2015 · 4 comments
Open

[last_modified] not in <time> format #2

schasoli opened this issue Apr 2, 2015 · 4 comments

Comments

@schasoli
Copy link

schasoli commented Apr 2, 2015

[last_modified] output is not html standard
is: 11/04/2015
should: 2015-04-11
see https://html.spec.whatwg.org/multipage/infrastructure.html#valid-date-string

function shortcode_last_modified() {
return the_modified_date( 'd/m/Y', '', '', false );
return the_modified_date( 'Y-m-d', '', '', false );

It would be also nice to have a shortcode to get the date using the WP date format as set in settings.

@schasoli
Copy link
Author

schasoli commented Apr 2, 2015

well, to stay as compatible as possible i added a new shortcode and tested
'last_modified_prefs' => array( $this, 'shortcode_last_modified_prefs' ),

changed
function shortcode_last_modified() {
/* return the_modified_date( 'd/m/Y', '', '', false );/
return the_modified_date( 'Y-m-d', '', '', false );
}
and added
function shortcode_last_modified_prefs() {
return the_modified_date('','','',false);
}

works fine for me.

@schasoli schasoli closed this as completed Apr 2, 2015
@schasoli schasoli reopened this Apr 2, 2015
@sheabunge
Copy link
Owner

Perhaps a good middle ground would be to include the standard YYYY-MM-DD format inside the datetime attribute on the <time> element, and then use the preferences format to display the date on the page. Something like this:

<time datetime="2015-04-21">21 April 2014</time>

@schasoli
Copy link
Author

schasoli commented Apr 3, 2015

w3c validator accepts it and pubdate is not used anymore. So I think yours is the best solution for a footer. I do it like this
$date1 = the_modified_date( 'Y-m-d', '', '', false );
return the_modified_date('','<time datetime="'.$date1.'">','</time>',false);

looking at http://html5doctor.com/time-and-data-element/ maybe this would be nice for google and co:
<article itemscope itemtype="http://schema.org/BlogPosting">

<data itemprop="datePublished" value="2015-04-21">21 April 2014</data></article>
But it would need to more shortcodes:
beginArticle, endArticel or so.
edit: https://wordpress.org/plugins/itempropwp/ could be used for this

@sheabunge
Copy link
Owner

I've updated the code to use the first format. I'm not entirely sure about using the second method; it looks more suited to a local article footer such as the area where categories, tags, published date, etc are displayed, not a global footer area which could be virtually anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants