Want to display my custom date archive to date.php but dont know how

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

Adding a number to a date

You need get_the_time, not the_time to get the date (the latter echo‘s the value). You also need to re-evaluate how you’re trying to calculate the end date – you can’t just “add” the number of days. What if the event length was 3 but the start date was the 31st? if ( $event_length ) { … Read more

Create a new post on a specified publish date via link?

Here is the solution I came up with! In my plugin functions: <?php function ficma_inline_script() { $datedata = explode(“-“, $_POST[‘date’]); $year = $datedata[0]; $month = $datedata[1]; $day = $datedata[2]; $newdate = date(“M d, Y”, mktime(0, 0, 0, $month, $day, $year)); ?> <script type=”text/javascript”> document.getElementById(“mm”).value = “<?=$month ?>”; document.getElementById(“cur_mm”).value = “<?=$month ?>”; document.getElementById(“hidden_mm”).value = “<?=$month ?>”; … Read more

Get posts by birthday

What you can do is create a meta field under a post and store birth date in that field. Now you need meta_query in you post to retrieve the current date posts. <?php $currentDate = current_time( ‘Y-m-d’ ); $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘birth_date’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ … Read more

How to display Date and Time in Tamil Language?

Unfortunately as describes it is far from trivial to display just the date in localized format. The function for localized date output in WP is date_i18n(). But it doesn’t have a concept of output in arbitrary locale. It always takes locale to use from global $wp_locale context. You would have to pretty much rebuild this … Read more

Comparing Dates within plugin using PHP If statement

$current_date is a timestamp and $compare_date is a formatted date, so you’re comparing different things. As you’re already using DateTime and as of PHP 5.2.2 DateTime objects can be compared using comparison operators, you can compare instead $expired_date (DateTime object) with today’s date as a DateTime object: $current_date = new DateTime(); $expired = new DateTime(); … Read more

Filter on the day of the week from timestamp

This answer may help someone who really wants to customize their filters. With PhpStorm and breakpoints I could walk through how the meta_query is constructed before posts are fetched. There are no hook points in the flow that let developers accomplish this; I’ve used a SQL-injection trick to achieve the filter. // Do advanced SQL … Read more

How do I display posts ordered by a date custom field?

I figured it out afterwards. Ended up using a different approach, I’m posting it in case someone has the same issue <?php date_default_timezone_set(‘America/Argentina/Buenos_Aires’); $posts_by_date_field = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘fecha’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_type’ => ‘DATE’ )); if ($posts_by_date_field->have_posts()) : while ($posts_by_date_field->have_posts()) : $posts_by_date_field->the_post(); // LOOP … Read more

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