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

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

Count posts for each year

The Easy Way This is by far and away the easiest approach to this, but unless you are willing to be a little bit flexible with how you present your archive it’s not for you. The easy solution is achieved using the wp_get_archives() function. Unfortunately though there is no filter available to manipulate the output, … 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 make a custom Archive Page

You can get the queried date from the query vars in the $wp_query object: if( is_date() ){ if( isset( $wp_query->query_vars[‘year’] ) ){ echo ‘queried year is ‘ . $wp_query->query_vars[‘year’]; } if( isset( $wp_query->query_vars[‘monthnum’] ) ){ echo ‘queried month is ‘ . $wp_query->query_vars[‘monthnum’]; } if( isset( $wp_query->query_vars[‘day’] ) ){ echo ‘queried day is ‘ . $wp_query->query_vars[‘day’]; … 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

How to show specific year archive into dropdown list

<?php function foo($where) { return $where . ‘ AND YEAR(post_date) = 2010 ‘; } add_filter(‘getarchives_where’, ‘foo’, 1, 10); ?> <select name=”archive-dropdown” onChange=”document.location.href=this.options[this.selectedIndex].value;”> <option value=””><?php esc_attr_e( __(‘Select Issue’) ); ?></option> <?php wp_get_archives(‘type=daily&format=option’); ?> </select> <?php remove_filter(‘getarchives_where’, ‘foo’, 1, 10); ?>

Create a month by month archive of pages (not posts)

You could probably hack something together, but you should probably understand that, in WordPress, a basic assumption (and operating principle) is that static Pages are not chronological. IMHO, a better approach would be to store the content as Blog Posts, and then to use Categories (or perhaps, a custom taxonomy) to identify that content, and … Read more

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