If X Amount of Time Has Passed Since Post Was Published, Do Something

What the current code does human_time_diff( get_the_time( ‘U’ ), current_time( ‘timestamp’ ) ) produces the time between when the post is published and the current time as a human readable string such as ‘6 days’. Meanwhile, strtotime( ‘7 days’ ) retrieves a integer timestamp representing 7 days after this moment, e.g. 1625673951. With that in … Read more

Custom Post Type or Shortcode, What to choose? [closed]

If building a multipurposetheme (Hello Themeforest!), I would always use a Custom Post Type for something like this. The reason is, as you already mentioned in your shortcode approach, you have too many fields and variables even in the beginning. Then, to have your Theme serve as many customers as possible, you have to add … Read more

Get previous posts list

Did you chceck the Codex Date Parameters ? Expecially the ‘before’ param.It works like this: $date = get_the_date(‘Y-m-d H:i:s’); $args = array( ‘date_query’ => array( array( ‘before’ => $date ), ), ‘posts_per_page’ => 10, ); $query = new WP_Query( $args );

How to display checked posts on another page over AJAX? (like comparasion style)

Add data-post_id attribute to checkbox and fill it with corresponding post ID. On click on compare button (link) retrieve all post ids from checked checkboxes with JavaScript (jQuery) Redirect to the comparision page with post IDs in url as GET parameters. This is just one scenario how your task could be done. PS your question … Read more

Conditional statement for dates

instead of $currentdate = current_time(‘Ymd’); you can use $currentdate = new DateTime(); so the Final Solution should be as like given below <?php $currentdate = new DateTime(); $date = get_field(‘course_start_date’, false, false); $date = new DateTime($date); if ($currentdate > $date) { echo ‘ – Started.’; } else { echo ‘ – Not started.’; } ?>