Opened 11 years ago
Closed 9 years ago
#23202 closed defect (bug) (wontfix)
Enable is_page_template() within the Loop
Reported by: | 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)
Change History (8)
#4
@
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.
Alternative solution