WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#19902 new feature request

blog_url() and get_blog_url() template tags

Reported by: johnjamesjacoby Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.3.1
Component: Permalinks Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description (last modified by johnjamesjacoby)

With usage of WordPress as a CMS increasing, the blog is not always the focal point. It would be great if there were template tags available to get the blog url, basically a wrapper for getting the options if it's set to a WordPress page, and defaulting to home_url( '/' ) if not.

Patched against r19759 (trunk)

Attachments (1)

19902.diff (1.5 KB) - added by johnjamesjacoby 2 years ago.

Download all attachments as: .zip

Change History (10)

johnjamesjacoby2 years ago

comment:1 follow-ups: nacin2 years ago

Since we already have site_url(), let's try to pick a name that is less confusing. Perhaps blog_page_url() or something.

This might be a duplicate of another ticket, but I'm not locating anything.

comment:2 in reply to: ↑ 1 ; follow-up: johnjamesjacoby2 years ago

Replying to nacin:

Since we already have site_url(), let's try to pick a name that is less confusing. Perhaps blog_page_url() or something.

This might be a duplicate of another ticket, but I'm not locating anything.

Agree the nomenclature gets increasingly confusing. Possible permutations:

  • get_/blog_url()
  • get_/blog_link()
  • get_/blog_permalink()
  • get_/blog_page_url()
  • get_/blog_page_link()
  • get_/blog_page_permalink()
Version 0, edited 2 years ago by johnjamesjacoby (next)

comment:3 johnjamesjacoby2 years ago

  • Description modified (diff)

comment:4 evansolomon2 years ago

I wrote a similar patch before finding this ticket, which covers pretty much everything I thought of. An additional idea I had was to return the last post if the blog uses a static front page but doesn't have a posts page set. In that case, I think the last post (if one exists) makes the most sense as their blog URL.

comment:5 in reply to: ↑ 1 ericlewis8 months ago

This is sorely needed.

Replying to nacin:

Since we already have site_url(), let's try to pick a name that is less confusing. Perhaps blog_page_url() or something.

I'm good with get_blog_url(), it fits well with the other link template tags we already have.

comment:6 SergeyBiryukov7 months ago

#25423 was marked as a duplicate.

comment:7 SergeyBiryukov7 months ago

Found a use case for get_blog_url() in wp_list_categories():
tags/3.6.1/wp-includes/category-template.php#L460.

comment:8 in reply to: ↑ 2 ericlewis7 months ago

Replying to johnjamesjacoby:

Agree the nomenclature gets increasingly confusing.

get_blog_index_url() and blog_index_url() is another naming option that read less confusing to me than get_blog_page_url() and blog_page_url(), and more specific than blog_url() and get_blog_url()

comment:9 nacin3 months ago

  • Component changed from Template to Permalinks
Note: See TracTickets for help on using tickets.