Custom Post Type Archives with 0 Posts Redirects as 404
An FYI for those coming back to this question, this was fixed in 3.2: http://core.trac.wordpress.org/ticket/17316
An FYI for those coming back to this question, this was fixed in 3.2: http://core.trac.wordpress.org/ticket/17316
One of the easiest (although not the only) of ways to achieve this is by creating a custom options panel in the WP dashboard that will allow your client to create and update information that can be used through out your template files with no technical knowledge being necessary. You can either paste the following … Read more
You can change it via the category template (if you have multiple category templates you’ll need to edit all of them; if you have archive.php, you need to edit it only there). Otherwise you can use the Yoast SEO plugin which have settings for naming the archives (actually I think that almost all SEO plugins … Read more
The Simple Yearly Archive Plugin does just that. This code will also do the trick: <?php // get years that have posts $years = $wpdb->get_results( “SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type=”post” AND post_status=”publish” GROUP BY year DESC” ); foreach ( $years as $year ) { // get posts for each year $posts_this_year = … Read more
index.php and archive.php might be the same but don’t have to be the same. index.php will display your blog post archive and in the absence of archive.php (or other more specific archive files) it will display your date, author, etc. archives as well. But it doesn’t have to. You can, if you want, display your … Read more
User Rarst has a very famous answer where he lays out the load process. Looking at this graph whenever wp-blog-header.php gets loaded it calls function wp() which sets up many of WordPress globals like $post and $wp_query. ( Secondary Reference by User Gmazzap ) That’s the technical side of things but it looks like the … Read more
Because an “archives” Page is not an archive index of blog Posts, but rather a Page. An “archives” page is simply a custom Page template, which applies to a static Page. The is_archive() conditional returns true if an archive index is being displayed. An archive index page displays Posts, not static Pages. EDIT Instead of … Read more
The code in the link you posted will (using pre_get_posts) will always change the number of posts_per_page to 3 if you are querying posts from that type. So a better solution would be to not use that code and simply above you code, before : <?php while( have_posts() ) : the_post(); ?> add: if ( … Read more
You can move the code from OP’s answer into a 404 template filter and force WP to load the date.php file instead of 404.php. It’ll still send the 404 header, but render the page with a different template. function wpd_date_404_template( $template=”” ){ global $wp_query; if( isset($wp_query->query[‘year’]) || isset($wp_query->query[‘monthnum’]) || isset($wp_query->query[‘day’]) ){ $template = locate_template( ‘date.php’, … Read more
If you want to get the month of the current archive page you’ll have to use single_month_title. The following code will output ” August 2014″ (notice the space before the month) <?php single_month_title(‘ ‘) ?> Without a space before the month: <?php echo trim(single_month_title(‘ ‘,false)) ?> Read more: http://codex.wordpress.org/Function_Reference/single_month_title