When the calendar widget is activated in the sidebar, it generates the following validation error (W3C markup validation):

The summary attribute is obsolete. Consider describing the structure of the table in a caption element or in a figure element containing the table; or, simplify the structure of the table so that no description is needed.

…alendar</h3><div id="calendar_wrap"><table id="wp-calendar"

How can I rectify this without messing with any core file?

Working with WP3.1.4, twentyten theme.


1 Answer 1


Update to 3.2.2. The summary attribute has been removed. See line 1149 \wp-includes\general-template.php

WP v3.1.4:

$calendar_output = '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">

WP v3.2.2:

$calendar_output = '<table id="wp-calendar">

Alternatives... To modify the output of the widget, you can duplicate it and rename it. When I did that, I also needed to duplicate the get_calendar() function and adjust the calls to apply_filters() and the caching functions. It was worth the work, because I wanted complete control of the calendar widget's output.

Another approach is to use the get_calendar filter and modify the output using str_replace, simple xml, regex, etc. Here's a solution using str_replace() (add this code to functions.php):

add_filter( 'get_calendar', 'customize_calendar_output' );
function customize_calendar_output( $calendar_output ) {
    $calendar_output = str_replace( '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">', '<table id="wp-calendar">', $calendar_output );
    return $calendar_output;
  • thanks for time and help. I prefer the Alternatives you mentioned, but I don get it. can you peovide more info please. thanks.
    – Tara
    Commented Oct 10, 2011 at 3:01
  • 10 continuing with my above comment, how can I filter $calendar_output = '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '"> to $calendar_output = '<table id="wp-calendar">
    – Tara
    Commented Oct 10, 2011 at 3:33
  • Updating WP is the best way for sure, but I've updated my answer with a solution using the get_calender filter. Commented Oct 10, 2011 at 4:23
  • 10, sorry I spoke to soon, the filter did not resolve the error
    – Tara
    Commented Oct 10, 2011 at 15:29
  • I tested it before I posted the code. It worked. Please give more details or show your code. If you do: add_filter( 'calendar_output', 'customize_calendar_output' ); function customize_calendar_output( $calendar_output ) { $calendar_output = '<h1>TEST TEST TEST</h1>' . $calendar_output; return $calendar_output; } does the h1 show up? Commented Oct 10, 2011 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.