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

AMP Get_the_date #1876

Closed
scorpaanon opened this issue Mar 15, 2018 · 2 comments
Closed

AMP Get_the_date #1876

scorpaanon opened this issue Mar 15, 2018 · 2 comments
Milestone

Comments

@scorpaanon
Copy link

function amp_date( $args=array() ) {
global $redux_builder_amp;
if ( 2 == $redux_builder_amp['ampforwp-post-date-format'] ) {
$args['format'] = 'traditional';
}
if ( (isset($args['format']) && $args['format'] == 'traditional') || 'time' == $args ) {
$post_date = esc_html( get_the_date() ) . ' '.esc_html( get_the_time());
} else {
$post_date = human_time_diff(
get_the_time('U', get_the_ID() ),
current_time('timestamp') ) .' '. ampforwp_translation( $redux_builder_amp['amp-translator-ago-date-text'],
'ago');
}
$post_date = apply_filters('ampforwp_modify_post_date', $post_date);
if(isset($args['custom_format']) && $args['custom_format']!=""){
$post_date = date($args['custom_format'],get_the_time('U', get_the_ID() ));
}
if ( 'date' == $args || 'time' == $args ) {
echo $post_date .' ';
}
else
echo '

'.$post_date.'
';

soultions??

echo get_the_date('F j, Y');

The get_the_date behavior is to always return a date, so if a post ID not given to a get_the_date call and you're not in a context where posts can be obtained (i.e. is_date() ), then as a last resort get_the_date will use the post_date field from the wp_posts . So There needs to be Post IDS In this query. Just my brief idea from PHP overview.

-KHII

#1864

@MARQAS
Copy link
Contributor

MARQAS commented Mar 16, 2018

Hi @scorpaanon
It's not due to the ID, it will automatically take the ID if it's in the loop.

The issue was due to one of your plugin called iWappPress which is changing the behavior of date and time functions by removing their filter. like
add_filter('get_the_time', '__return_false');

MARQAS added a commit that referenced this issue Mar 16, 2018
It was due to conflict with another plugin.

Also connected the swift date with AMP options panel
@MARQAS MARQAS added this to the W10 milestone Mar 16, 2018
@MohammedKaludi
Copy link
Collaborator

👍

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

3 participants