Get the Blog Page URL in WordPress

WordPressPosted on

In WordPress, we can set a static page to the blog listing (and to the front page). In this case, we sometimes want to get its URL from the code.

We can get the URL at least three ways:

The site_url() function retrieves the URL for the current site, where we can set an additional path.

echo esc_url(site_url('/blog/'));

Usint the get_option() we can retrive the page_for_posts option data. This identifies the blog post page’s ID wich we can pass to the get_permalink() function.

echo esc_url(get_permalink(get_option('page_for_posts')));

From WordPress 4.5.0 we can use the get_post_type_archive_link() function to retrive the post list page (which is commonly called blog).

echo esc_url(get_post_type_archive_link('post'));

Need a web developer? Maybe we can help, get in touch!

Looking for web dev job?
You can check them on Jooble.

To see and write comments, you must allow the related (Disqus) cookies. For more information, please visit our privacy policy page.

Similar Posts

More content in WordPress category