WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#12958 closed enhancement (fixed)

locate_template restricts the use of get_template_part

Reported by: w3prodigy Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: Themes Keywords:
Focuses: Cc:

Description

The locate_template functions utilizes require_once to include files. With get_generic_template providing the ability to simply include template files we should make it more flexible so users can include the same file twice from one template file.

For example if I wanted to create a custom template for a parent page with children and display the content from the children on the parent page I would use get_generic_template('loop','page') for the loop for the parent page, followed by another get_generic_template('loop','page') for each child page.

I suggest we replace the require_once function of locate_template with a require function to increase the administrators accessibility to template files.

Change History (6)

#1 @w3prodigy
9 years ago

  • Summary changed from locate_template restricts the use of get_generic_template to locate_template restricts the use of get_template_part

Sorry, originally referenced get_generic_template when that function has been renamed to get_template_part.

#2 @scribu
9 years ago

  • Keywords reporter-feedback added

locate_template() doesn't do any including or requiring; it just finds the first available file and returns it's path. So I'm not sure what you're refering to.

#3 @scribu
9 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Unassigned to 3.0
  • Type changed from feature request to enhancement

It's actually load_template() that does the requiring. We could probably add a $once paramater to it.

#4 @scribu
9 years ago

  • Component changed from General to Themes

#5 @nacin
9 years ago

the _once seems historical: [2023]. That said, simply changing it could cause some themes to display multiple headers due to multiple calls to get_header(), etc.

No problems adding a $require_once parameter.

#6 @nacin
9 years ago

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

(In [14075]) Don't use require_once for get_template_part(). fixes #12958.

Note: See TracTickets for help on using tickets.