Default archive URL wordpress

This may be an old question, but all the answers here are incorrect.

If the front page is set to a static page, and another page is set to the blog page, this will dynamically fetch and echo the URL for the blog archive page (i.e. blog index page)…

<?php echo get_permalink( get_option( 'page_for_posts' ) ) ?>

This first fetches the page id for your blog page (from your site options), then fetches the permalink for that page id.

From a coding standpoint, WordPress assumes that your homepage and your blog page are one and the same. This is vestigial functionality from the days when WordPress was literally just a blog system, and not the full-featured CMS it has become. As such, you cannot generally trust the naming convention of WordPress’s core functions.

FOR EXAMPLE: home_url() will generally return your homepage, whatever it is… which may not necessarily be your main blog archive/index. However, the conditional is_home() function returns true only for your main blog archive not your actual homepage (which is tested using is_front_page()).

Leave a Comment