Switch Categories on a Specific Date?

I don’t know if this can be accomplished with WP alone. I would create two custom fields for your posts. First custom field would hold the date you want make the switch Second field would hold the category you want the post to switch to (Assuming it’s not always the same post and not always … Read more

Update post date of page when Visitor access that page?

You can hook into the action the_post (you get the post as parameter here) and run wp_update_post(). Make sure to clean up the date properties and not to run on the admin side or when a post is called in a widget: is_admin() or add_action( ‘the_post’, function( $post ) { if ( ! is_singular() or … Read more

Change News Story Layout Based on Date Range

Conceptually, that isn’t hard to do. if (have_posts()) { while (have_posts()) { the_post(); if ( $post->post_date >= date(“Y-m-d H:i:s”,strtotime(‘7/15/03 1:03 PM’)) && $post->post_date <= date(“Y-m-d H:i:s”,strtotime(‘9/19/07 11:34 AM’))) ) { // (layout coding) } elseif ( /* another condition */ ) { // (layout coding) } elseif ( /* another condition */ ) { // … Read more

Show different time stamp based on time

Check out human_time_diff(): if ( DAY_IN_SECONDS < ( $time = current_time( ‘timestamp’ ) ) – ( $time_post = get_the_time( ‘U’ ) ) ) echo human_time_diff( $time_post, $time ) . ‘ ago’; else the_time( ‘F j, Y at g:i a’ ); DAY_IN_SECONDS is a handy “helper” constant in WordPress, along with: MINUTE_IN_SECONDS HOUR_IN_SECONDS WEEK_IN_SECONDS YEAR_IN_SECONDS

display future posts in date page

You can alter the query with pre_get_posts before it’s run to include future posts: function wpd_future_date_archives( $query ){ if( $query->is_date() && $query->is_main_query() ) { $query->set( ‘post_status’, array( ‘publish’, ‘future’ ) ); } } add_action( ‘pre_get_posts’, ‘wpd_future_date_archives’ ); The posts won’t behave the same as published posts though- they have no pretty permalink until they’re published.

Sort / display recent posts by publish date

The Recent Posts widget, and the posts page for that matter, doesn’t display ordered by update date, it orders by published date. If it’s displaying by updated date then you must have a plugin somewhere that’s changing this behaviour, or are using something other than the standard Recent Posts widget.

Date Language doesn’t change

The date() is a native PHP function. Its output depends on PHP locale and timezone settings. In a typical WP environment that would be default English locale and UTC time zone (which WP sets during core boot). Since WP implementation of Date/Time component predates PHP 5 and its enhancements, it has a lot of own … Read more

Docker Container time & timezone (will not reflect changes)

The secret here is that dpkg-reconfigure tzdata simply creates /etc/localtime as a copy, hardlink or symlink (a symlink is preferred) to a file in /usr/share/zoneinfo. So it is possible to do this entirely from your Dockerfile. Consider: ENV TZ=America/Los_Angeles RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone And as a bonus, TZ will … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)