WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#25423 closed enhancement (duplicate)

Add a template link template function for getting a permalink to the blog index

Reported by: ericlewis Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Template Keywords:
Focuses: Cc:

Description

There is currently no link template function to get the blog index permalink easily, although we have a plurality for more granular blog archives (get_day_link(), get_search_link(), etc).

Change History (3)

#1 @ericlewis
8 years ago

I'll suggest get_blog_url() to match the general naming conventions of other link template functions ( e.g. get_admin_url() ).

I'm sure there are a multitude of setups that I am unfamiliar with that go back to the 1.0 days we'll have to cover for backwards compatibility, so excuse the naive in my starter-code suggestion:

function get_blog_url() {
	// If a page is set to show the blog index, return that.
	if ( get_option( 'page_for_posts' ) ) 
		return get_permalink( get_option( 'page_for_posts' ) );

	// If there is a page on front, there is no blog index.
	if ( 'posts' === get_option( 'show_on_front' ) )
		return site_url();

	// Otherwise, there is no blog index.
	return false;
}

#2 @SergeyBiryukov
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #19902.

#3 @ericlewis
8 years ago

Wow, I opened up a ticket that's a duplicate of another ticket I've already commented on :P

Note: See TracTickets for help on using tickets.