![](/style/images/good.png)
![](/style/images/bad.png)
Get the Blog Page URL in WordPress
source link: https://pineco.de/snippets/get-the-blog-page-url-in-wordpress/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
We use cookies for commenting and analytics. For more details, please visit our privacy page.
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'));
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK