How to display on the first page when the article was submit, for example: 18 days ago, 2 minutes ago and to display the date on the other pages.
I understand it should use a if else condition.
Thanks.
How to display on the first page when the article was submit, for example: 18 days ago, 2 minutes ago and to display the date on the other pages.
I understand it should use a if else condition.
Thanks.
have you located the code where the date/time is displayed?
possible conditional tags to use:
is_home() http://codex.wordpress.org/Function_Reference/is_home
or
is_front_page() http://codex.wordpress.org/Function_Reference/is_front_page
is_paged() http://codex.wordpress.org/Function_Reference/is_paged
http://codex.wordpress.org/Conditional_Tags
http://codex.wordpress.org/Function_Reference/human_time_diff
thanks for your answer.
This code didn't worked.
<?php
if ( is_front_page() ) {
echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago';
} else {
echo 'x';
}
?>
Is just displaying like "2 hours ago" even if I'm on page 2.
that is whateven if I'm on page 2
is_paged() is for.
example:
if ( is_front_page() && !is_paged() )
or try:
if ( is_home() && !is_paged() )
Worked with this, thank you sir.
<?php
if ( is_home() && !is_paged() ) {
echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago';
} else {
echo the_time('d.m.Y');
}
?>You must log in to post.