display archive as collapsing links
display archive as collapsing links
display archive as collapsing links
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
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
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
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
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
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
<?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); ?>
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
You can just use a normal query to grab all posts (which are, by default, sorted date descending), and break them up as you loop over them: <?php $posts = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘press-releases’ ) ); if ( $posts->have_posts() ) : ?> <ul class=”accordion”><?php while ( $posts->have_posts() ) : $posts->the_post(); … Read more