Make WordPress Core

Opened 6 years ago

Last modified 19 months ago

#12016 reviewing defect (bug)

get_calendar can output a calendar when there are no posts

Reported by: mtdewvirus Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: has-patch 2nd-opinion
Focuses: template Cc:


If a site doesn't have any posts, get_calendar isn't supposed to display a calendar. You can visit a page or have a static home page, and a calendar is displayed. The get_calendar function is looking at global $posts to determine if the site has posts but this variable can contain data from other post_types.


Attachments (2)

bmb_0005_t12016.patch (1.1 KB) - added by bumbu 5 years ago.
bmb_0006_t12016.patch (914 bytes) - added by bumbu 5 years ago.
the same with less code

Download all attachments as: .zip

Change History (9)

@bumbu5 years ago

comment:1 @bumbu5 years ago

  • Cc bmbalex@… added
  • Owner set to bumbu
  • Status changed from new to reviewing

In this patch if $pages exist, function additionally is looking if it contains at least one published post, if no it is looking into DB for this

@bumbu5 years ago

the same with less code

comment:2 @bumbu5 years ago

  • Keywords has-patch added; calendar removed
  • Owner bumbu deleted

comment:3 @dd325 years ago

I'm not sure i agree with this function not displaying a calender just because i'm viewing a page, or custom post_types..

Many would expect it to either

  1. Always display the latest posts as selected


  1. Display a calender based upon the selected post_type (Thats a whole can of worms however)

comment:4 @ryan5 years ago

  • Milestone changed from 3.0 to 3.1

comment:5 @nacin5 years ago

  • Keywords 2nd-opinion added
  • Milestone changed from Awaiting Triage to Future Release

comment:6 @nacin20 months ago

  • Component changed from General to Template

comment:7 @nacin19 months ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added
Note: See TracTickets for help on using tickets.