Issue with strtotime() and Meta Box date
For some reason, strtotime didn’t recognise the date format d.m.y. m/d-y is save. Then it worked.
For some reason, strtotime didn’t recognise the date format d.m.y. m/d-y is save. Then it worked.
You create two date objects and compare with the diff() methode. $from = new DateTime( ‘1970-01-01’ ); $to = new DateTime(‘today’); $years = $from->diff($to)->y; $months = $from->diff($to)->m; echo $years . ‘ years and ‘ . $months . ‘ months.’; => 46 years and 1 months.
You could try to set a Transient and set its expiration to 3 months. Once it expires, it can trigger a message or some other behavior that alerts the user about the timeframe.
To search for posts based on date, you can set up a quick instance of WP_Query. The best place to look is the official documentation, and in particular the section on the date parameters. A basic search for posts in a particular month will look a little like this: <?php $the_query = new WP_Query( array( … Read more
You can use WP_Query to query posts from Date A to Date B, here are all Date Parameters for the WP_Query object : //////Date Parameters – Show posts associated with a certain time and date period. //http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters ‘year’ => 2014, //(int) – 4 digit year (e.g. 2011). ‘monthnum’ => 4, //(int) – Month number (from … Read more
I was able to receive the solution from the developer. Add the below code into functions.php and then rebuild the Relvanssi index. This worked for me. function rlv_index_post_date( $content, $post ) { $date = get_the_time( “F Y”, $post->ID ); $content .= ” $date”; return $content; } add_filter( ‘relevanssi_content_to_index’, ‘rlv_index_post_date’, 10, 2 );
You can use the get_the_time() to get the post time . <?php get_the_time( $format, $featured_post->ID ); ?> See the tutorial https://codex.wordpress.org/Function_Reference/get_the_time
According to the codex, you’re manipulating get_most_recent_post_of_user()‘s returned value the wrong way. get_most_recent_post_of_user() directly returns the post_date_gmt among blog_id, post_id, and post_gmt_ts. Anyway, if you want to get the 2 last posts of a specific author, use WP_Query instead, which should by default get last posts in the order you need. $author_id = $author_id; $args … Read more
You will need to write a custom rewrite rule for this. Just copy the following code into your functions.php and flush rewrite rules. function xlinkerz_custom_archive_rewrite_rule( $rewrite_rules ) { $custom_slug = ‘custom_archive’; $year_rule = array( $custom_slug . ‘/([0-9]{4})/([0-9]{1,2})/?$’ => ‘index.php?year=$matches[1]&monthnum=$matches[2]’ ); $month_rule = array( $custom_slug . ‘/([0-9]{4})/?$’ => ‘index.php?year=$matches[1]’ ); // Merging rules $rewrite_rules = $year_archive … Read more
Use current_time to output the time based on the timezone set on the blog’s General Settings page.