Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#23202 closed defect (bug) (wontfix)

Enable is_page_template() within the Loop

Reported by: wpsmith's profile wpsmith Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch reporter-feedback
Focuses: template Cc:

Description

There have been a few times where, in the loop, I need to know if I were on a page using a specific page template.

The function in_the_loop() provides this functionality for us to expand is_page_template().

Attachments (2)

23202.patch (779 bytes) - added by wpsmith 11 years ago.
23202.alt.patch (1.1 KB) - added by wpsmith 11 years ago.
Alternative solution

Download all attachments as: .zip

Change History (8)

@wpsmith
11 years ago

#1 @alexvorn2
11 years ago

  • Component changed from General to Template

#2 @wpsmith
11 years ago

  • Keywords has-patch dev-feedback added

@wpsmith
11 years ago

Alternative solution

#3 @nacin
10 years ago

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

#4 @nacin
10 years ago

Unless I'm reading this wrong, it seems like the issue here is the usage of query_posts(). query_posts() does change the active $wp_query and thus all conditionals.

This should work fine if you're on a page with a page template inside a loop. But *the* loop doesn't really make any sense as that should be the actual page (singular).

Alternatively, if it's proposing that it should work inside the loop for the current page: I think this would break things by changing the return value. While can take a function and make it work outside of the loop, taking a function and changing its behavior inside the loop is gonna cause problems.

Maybe I just don't understand the problem.

#5 @obenland
9 years ago

  • Keywords reporter-feedback added; dev-feedback removed

Travis, would you mind elaborating the use case?

#6 @wonderboymusic
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

No response in a year.

Note: See TracTickets for help on using tickets.