how do I get the date in a date archive page

Use get_query_var() to get the date parts: $year = get_query_var(‘year’); $monthnum = get_query_var(‘monthnum’); $day = get_query_var(‘day’); In wp_title() a call to get_query_var(‘m’) is used for the month too, but I got always just a 0 as value even on an URL like /2008/09/05/. If you want to print the month name, use: $GLOBALS[‘wp_locale’]->get_month($monthnum); The month … Read more

Display custom post types by date field

I solved the same problem like this First you store each posts in another array called $events_by_date with date as the index. If another event post falls in the same date you put that post under the same index. Please comment if you need further explanation. <?php //setup your wp_query parmeters to make the query … Read more

Custom Post Types – How to include custom fields

@vemuez you need to enqueue js and css files to admin_print_script and admin_print_style here is the example to how to do it // Register datepicker ui for properties function admin_homes_for_sale_javascript() { global $post; if($post->post_type == ‘homes-for-sale’ && is_admin()) { wp_enqueue_script(‘jquery-ui-datepicker’, WP_CONTENT_URL . ‘/themes/yourthemename/js/jquery-ui-datepicker.min.js’); } } add_action(‘admin_print_scripts’, ‘admin_homes_for_sale_javascript’); // Register ui styles for properties function admin_homes_for_sale_styles(){ … Read more

How can I change the way dates shown in the archive widget?

For archives you can use the get_archives_link filter like this: add_filter(‘get_archives_link’, ‘translate_archive_month’); function translate_archive_month($list) { $patterns = array( ‘/January/’, ‘/February/’, ‘/March/’, ‘/April/’, ‘/May/’, ‘/June/’, ‘/July/’, ‘/August/’, ‘/September/’, ‘/October/’, ‘/November/’, ‘/December/’ ); $replacements = array( //PUT HERE WHATEVER YOU NEED ’01.’, ’02.’, ’03.’, ’04.’, ’05.’, ’06.’, ’07.’, ’08.’, ’09.’, ’10.’, ’11.’, ’12.’ ); $list = preg_replace($patterns, … Read more

Making next_posts_link(); return posts by month

You have to modify the query that selects the posts to select by month. This bit of code placed in the template will get the page number and subtract that from the current month. <?php $page = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; $subtractor = $page-1; $date = date(“Y-m-d H:i:s”); $current_month = date(‘n’, strtotime($date.’-‘.$subtractor.’months’)); $current_year = … Read more

How to get the date dynamically from archive.php to date.php?

It’s working very fine after I made some changes / adding on two php files function.php and date.php function.php function wpa_date_posts_per_page( $query ) { if ( !is_admin() && $query->is_date() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, -1 ); } } add_action( ‘pre_get_posts’, ‘wpa_date_posts_per_page’ ); date.php <?php get_header(); while (have_posts()) : the_post(); echo the_title() . ‘<br/><br/>’; endwhile; … Read more

Archive filtering posts by year and month

That’s trivial, we can exploit how WordPress URLs work and pass the query vars directly in the URL: <form action=”/” method=”GET”> <select name=”year”> <option value=”2017>2017</option> … etc .. </select> <select name=”month”> <option value=”01>01</option> … etc .. </select> <input type=”submit” value=”Filter”/> </form> WP will then see that it’s a date archive, it may even 301 redirect … Read more

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