wp_get_archives ignores blog page
-
For some reason it appears as if wp_get_archives() is ignoring the homepage of the blogs posts (ie. the “Posts page” setting under Settings -> Reading). For instance, the Posts page is set to /blog/, and this code:
$args = array( 'type' => 'yearly', 'limit' => '', 'format' => 'custom', 'before' => '<div class="arch-single"><span class="btn arch-toggle">', 'after' => '</span></div>', 'show_post_count' => false, 'echo' => 1, 'order' => 'DESC', 'post_type' => $post_type ); wp_get_archives( $args );
is generating this html:
<span class="btn arch-toggle"><a href='https://site.com/2017/'>2017</a></span> <span class="btn arch-toggle"><a href='https://site.com/2016/'>2016</a></span>
While those date based root links do show the archives, things like pagination appear to not work, and $wp_query->max_num_pages returns 1 page even when there should be more. However, the correctly structured links, https://site.com/blog/2017/, allow pagination and $wp_query->max_num_pages to return the correct results. Is there a parameter to add in a url prefix for the archives? Shouldn’t it be automatically adding the /blog/ to the url, since that is the posts page?
-Michael
- The topic ‘wp_get_archives ignores blog page’ is closed to new replies.