List archive year – post by post

Here is a strip down of something similar I’ve done a while ago. Here is what the code basically does is: First, it retrieves the date of the first post on the block. Secondly, the current date is retrieved. These two values are fed into a range() function to get all years in between A … Read more

WP Archive & Category Pages not filtering

From the codex for get_posts() The category parameter needs to be the ID of the category, and not the category name. So you should either use category_name parameter with name or you could pass the ID to category. <?php $term_name = get_queried_object()->name; $args = array ( ‘category_name’ => $term_name, ‘posts_per_page’ => 5); $myposts = get_posts( … Read more

Create page like custom post type list in WordPress

One option is to set has_archive to false when you register the CPT. Then, create a Page with the same slug. So if your CPT is “mycpt” then create a Page at http://example.com/mycpt/. From there, set up a custom Page template to act like an archive, but you can also (optionally) add content in the … Read more

Show monthly or daily archives

Before WordPress 4.1, you can show the date archive page titles with the following code: (Taken and slightly modified from the twentyfourteen theme) if ( is_day() ) { printf( __( ‘Daily Archives: %s’, ‘twentyfourteen’ ), get_the_date() ); } elseif ( is_month() ) { printf( __( ‘Monthly Archives: %s’, ‘twentyfourteen’ ), get_the_date( _x( ‘F Y’, ‘monthly … Read more