WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 5 years ago

#10968 closed enhancement (fixed)

Add container_element arg to wp_page_menu()

Reported by: stebbiv Owned by: paulwilde
Milestone: 4.4 Priority: lowest
Severity: minor Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: template Cc:

Description

I have added a new argument to the wp_page_menu template tag so it replaces the container div with another HTML element.

This is useful when migrating to HTML 5 and you want to use the <nav> element.

Attachments (5)

post-template.php.diff (1.5 KB) - added by stebbiv 11 years ago.
A simplified diff. Now container_element simply defaults to 'div'
wp_page_menu-container.diff (1.7 KB) - added by paulwilde 7 years ago.
10968.diff (1.5 KB) - added by wonderboymusic 5 years ago.
10968.2.patch (1.7 KB) - added by dlh 5 years ago.
10968.patch (2.2 KB) - added by DrewAPicture 5 years ago.
s/menu_tag/container + .2

Download all attachments as: .zip

Change History (22)

#1 @scribu
11 years ago

You forgot to replace the </div>

#2 @scribu
11 years ago

  • Summary changed from A new argument to replace the container div in wp_page_menu to Add container_element arg to wp_page_menu()

#3 @stebbiv
11 years ago

I have updated the diff file.

#4 @stebbiv
11 years ago

  • Cc stebbiv@… added

@stebbiv
11 years ago

A simplified diff. Now container_element simply defaults to 'div'

#5 @scribu
11 years ago

  • Keywords has-patch added
  • Milestone changed from Unassigned to 2.9

#6 @ryan
11 years ago

  • Milestone changed from 2.9 to Future Release

#7 @johnbillion
7 years ago

  • Keywords needs-refresh good-first-bug added; has-patch removed
  • Priority changed from normal to lowest
  • Severity changed from normal to minor

#8 @paulwilde
7 years ago

Refreshed patch.

I've opted for "menu_element" rather than "container_element", as container suggest a separate container outside of the menu when compared to wp_nav_menu.

#9 @paulwilde
7 years ago

  • Keywords has-patch added; needs-refresh removed

#10 @nacin
7 years ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

#11 @nacin
7 years ago

  • Owner set to paulwilde
  • Status changed from new to assigned

@wonderboymusic
5 years ago

#12 @wonderboymusic
5 years ago

  • Milestone changed from Future Release to 4.4

#13 @wonderboymusic
5 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34280:

Add an argument to wp_page_menu(), 'menu_tag', which defaults to div but can be overridden to allow HTML5 tags like nav.

Props paulwilde, stebbiv, wonderboymusic.
Fixes #10968.

@dlh
5 years ago

#14 @dlh
5 years ago

In [34280], it looks like $tag is created but not used. The attached patch would also add $menu_tag to the changelog.

#15 @obenland
5 years ago

We could also automatically use a nav element if the current theme supports html5.

@DrewAPicture
5 years ago

s/menu_tag/container + .2

#16 @DrewAPicture
5 years ago

  • Keywords good-first-bug removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Let's also create a little parity with wp_nav_menu and use container for the argument name instead of menu_tag.

10968.patch combines @dlh's .2 patch with the argument name change.

#17 @wonderboymusic
5 years ago

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

In 34307:

After [34280], rename menu_tag arg to container, fix docs.

Props DrewAPicture.
Fixes #10968.

Note: See TracTickets for help on using tickets.