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();
}
}
}
Written by Gilbert Pellegrom
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#