Where developers come to connect, share, build and be inspired.


WordPress get_blog_url()


Have you ever needed to find the WordPress blog URL? Using home_url() is fine but what if your Settings > Reading options in WordPress are set to your blog having a static page (usually called “Blog”). You may need to know what the URL of that page is. So here is a quick function I came up with to find it.

if ( !function_exists( 'get_blog_url' ) ) {
    function get_blog_url(){
        if( $posts_page_id = get_option('page_for_posts') ){
            return home_url(get_page_uri($posts_page_id));
        } else {
            return home_url();

Add a comment