WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#33309 closed enhancement (duplicate)

Add support to add page template via theme_page_templates filter

Reported by: prionkor Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

theme_page_templates (https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-theme.php#L1022) does not currently allow for page templates to be added.

I am wondering is there any good reason for that? Not allowing additional template to be added beats the purpose of the filter.

Can we have the filter ability to add page templates?

Change History (2)

#1 @dd32
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 4.2.4 deleted

The filter was designed to allow the renaming & removal of templates from being listed, simply adding a new page template via that filter wouldn't actually allow the template to be used (even if the function was changed to allow it).

See #13265 for a long discussion over being able to add templates via a filter.

#2 @prionkor
5 years ago

Thanks good read!

simply adding a new page template via that filter wouldn't actually allow the template to be used

I am developing a theme with MVC structure where there is a template factory which take care of the all templating.

The reason I was trying to use this filter want to have user select a (fake) page template. And If selected depending on the template name the template class can choose the right view class for it.

I will add a reply on that ticket.

Note: See TracTickets for help on using tickets.