WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 10 years ago

#6139 closed defect (bug) (worksforme)

is_year() returns false on year archive pages under /blog (or any non-root blog locale)

Reported by: forgetcolor Owned by:
Milestone: Priority: high
Severity: normal Version: 2.8.4
Component: General Keywords: is_year
Focuses: Cc:

Description

Summary:

is_year() should return true on a year archive page, such as domain.com/2008. if you change the custom permalink structure and static front page setup so that your blog lives under /blog, then is_year() will no longer return true for year archives, such as domain.com/blog/2008.

To reproduce the bug:

  1. setup a new 2.3.3 install with the default theme
  2. write a blank new post and publish
  3. visit the site and go to a year/month archive, such as domain.com/2008/03. the header of the page will appropriately read 'Archive for March, 2008'.
  4. visit the site and go to a year archive, such as domain.com/2008. the header of the page will appropriately read 'Archive for 2008.'

The above works as it should. Now, follow these additional steps to reproduce the bug:

  1. create a new Page called 'blog' with slug 'blog' (default template)
  2. create a new Page called 'home' with slug 'home' (default template)
  3. go to options->reading, set the front page to 'a static page' and select 'home' as the front page and 'blog' as the posts page
  4. go to options->permalinks, select custom, and set it to /blog/%year%/%monthnum%/%postname%/
  5. visit the site and go to a year/month archive, such as domain.com/blog/2008/03. the header of the page will (appropriately) read 'Archive for March, 2008.' this comes from a conditional in the theme using is_month(), which returns true. now visit domain.com/blog/2008. this should trigger the is_year() conditional in the same file so that it prints 'Archive for 2008', but it does not. this is because is_year() is returning false now that the blog lives under /blog.

It appears that the event that triggers this is adding /blog to the front of the custom permalink structure.

Change History (10)

#1 @lloydbudd
12 years ago

  • Milestone changed from 2.3.4 to 2.6

#2 @Denis-de-Bernardy
11 years ago

  • Resolution set to invalid
  • Status changed from new to closed

As I understand things, it's the expected behavior with the current code. Your year page would end up at site.com/year no matter what the permalink structure.

#3 @DD32
11 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Needs testing a bit more i think...

In the event that the permalinks are set to /blog/%year%/... the yearly archive is at /blog/2009/

In the even that the permalinks are set to /%year%/ yet a page is on the homepage, then it'll be at /2009/

#4 @Denis-de-Bernardy
11 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

right. and confirming blog/2009 works fine in that case, including is_year().

#5 @DD32
11 years ago

..Yep, just confirmed myself, In future, "Worksforme" is a better closure for that though.

#6 @jacobsantos
11 years ago

  • Milestone 2.9 deleted

#7 @fob
11 years ago

  • Cc fob added
  • Keywords is_year added
  • Milestone set to 2.8.5
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version set to 2.8.4

Since upgrading from 2.7.1 to 2.8.4 I have a similar problem:

../blog/2006/, ../blog/2007/ and ../blog/2008/ suddenly show me results from ../blog/.

If is_year() results are paged (normally they are) you can load ../blog/2008/page/1/ with the expected posts, ../blog/2008/page/2/ works fine, too, ... but if is_year start page seems to be replaced by rewind results of the blog page, first.

Monthly archives, archives by day or category and even paged results work fine. Resetting the permalink structure does not help at this time. I even could not locate a plugin failure to solve the ploblem.

(PHP5, mySQL5)

#8 @MikeLittle
10 years ago

I cannot reproduce this problem.

I have tried a brand new trunk install, followed the instruction in the original ticket and it works for me.

I also tried upgrading from 2.7.1 to 2.8.4 it still worked for me.

Recommend re-closing this one as worksforme.

#9 @MikeLittle
10 years ago

  • Cc wordpress@… added

#10 @ryan
10 years ago

  • Milestone 2.9 deleted
  • Resolution set to worksforme
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.