WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#16681 closed defect (bug) (worksforme)

The output from wp_list_bookmarks() fails to validate in Wordpress 3.1

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

Description

When run through the W3C's validator (validator.w3c.org), a page containing the example code for this function, as shown in the codex, will generate an error for each link category header, similar to:

Error Line 264, Column 36: document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag

<li id="linkcat-45" class="linkcat"><h2>Local Campaigns</h2>

The cause of this is that the list lacks an outer set of <ul>...</ul> tags, meaning that the header list items are not within a list context (unlike the nested lists for the links themselves).

Adding an outer set of unordered list tags resolves this issue, and the page will validate successfully.

Attachments (2)

check_before.html (20.1 KB) - added by robhogg 3 years ago.
Output from W3C validator, showing error on page validation.
bookmark-template.patch (925 bytes) - added by robhogg 3 years ago.
Patch for wp-includes/bookmark-template.php

Download all attachments as: .zip

Change History (4)

robhogg3 years ago

Output from W3C validator, showing error on page validation.

robhogg3 years ago

Patch for wp-includes/bookmark-template.php

comment:1 robhogg3 years ago

Updated the patch file.

comment:2 ocean903 years ago

  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

You should use

<ol>
    <?php wp_list_bookmarks(); ?>
</ol>

or

<ul>
    <?php wp_list_bookmarks(); ?>
</ul>

It's the same as for wp_list_comments() and wp_list_categories(). See also the codex for examples.

Note: See TracTickets for help on using tickets.