How to show different timestamp
This should do it. // See if the post is older than 24 hours. if ( get_post_time() <= strtotime( ‘-1 day’ ) ) { echo ‘Published more than 24 hours ago.’; } else { echo ‘Published within the last 24 hours.’; }
This should do it. // See if the post is older than 24 hours. if ( get_post_time() <= strtotime( ‘-1 day’ ) ) { echo ‘Published more than 24 hours ago.’; } else { echo ‘Published within the last 24 hours.’; }
This code requires both a width greater than or equal to 1, and a caption. You could try removing these lines: if ( $atts[‘width’] < 1 || empty( $atts[‘caption’] ) ) return $content; That may affect other functionality, but it is the point where the script skips the image entirely.
You need to grab the WordPress date option on the first parameter of date_i18n function : date_i18n( get_option( ‘date_format’ ), strtotime( ’11/15-1976′ ) ); You can see this example in the function codex page : date_i18n()
For the date Woocommerce CODE function wc_string_to_datetime( $time_string ) { // Strings are defined in local WP timezone. Convert to UTC. if ( 1 === preg_match( ‘/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|((-|\+)\d{2}:\d{2}))$/’, $time_string, $date_bits ) ) { $offset = ! empty( $date_bits[7] ) ? iso8601_timezone_to_offset( $date_bits[7] ) : wc_timezone_offset(); $timestamp = gmmktime( $date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1] ) – … Read more
How about something like this? $args = array( ‘date_query’ => array( array( ‘before’ => array( ‘year’ => 2013, ‘month’ => 2, ‘day’ => 28, ), ‘inclusive’ => true, ), ), ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); Obviously you could set the exact date from a variable. More info: https://codex.wordpress.org/Class_Reference/WP_Query
You might need to convert the time to timestamps (not php time formatting) for comparison purposes. I always found that it solved a lot of my event issues.
Try this: $q = new WP_Query; $posts = $q->query( array( ‘posts_per_page’ => 1, ‘orderby’ => ‘post_modified’, // Sorts by the date modified. ‘order’ => ‘DESC’, // Sorts in descending order. ‘no_found_rows’ => true, ) ); // Note that $posts could have more than one post, if your site have sticky // posts. However, the first … Read more
There are various ways to solve this. First coming to mind are checking via is_singular() or get_post_type(). Using the latter you could write foreach( $posts as $p ): setup_postdata( $p ); $post_type = get_post_type($p); if ($post_type === Tribe__Events__Main::POSTTYPE) { //or: if ($post_type === ‘tribe_events’) { // Display the date of the event $p_event = tribe_get_start_time … Read more
What you’re trying isn’t possible with WP_Query. The reason is that because you have only stored the duration, it’s not possible to tell whether a post has expired until you know the publication date and the duration time and add them together. That’s what this does: $expire = get_field( ‘status_time_duration’ ) + get_the_time( ‘U’ ); … Read more
Putting aside the legal issues, and focusing on a function for displaying the current year, the problem is actually pretty straightforward: The theme developer gave you the wrong code. get_the_date( ‘Y’ ) gets the year of the publication date of the current post. This is not what you asked for. date( ‘Y’ ) is a … Read more