Opened 17 years ago
Closed 17 years ago
#10048 closed defect (bug) (invalid)
Condition tag is_home() returns wrong result if it is called after query_posts()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | high | |
| Severity: | major | Version: | 2.8 |
| Component: | General | Keywords: | |
| Focuses: | Cc: |
Description
Pre-requisites:
Prepare a test-purpose php script, say:
$home = is_home() ? 'you are home': 'you are NOT home';
echo '<script type="text/javascript">alert("'.$home.'")</script>';
query_posts('showposts=1');
$home = is_home() ? 'you are home': 'you are NOT home';
echo '<script type="text/javascript">alert("'.$home.'")</script>';
Repro Steps
- Insert the test-purpose php script into a template php file, say single.php, then save.
- Visit any single post page in the blog
Expected Result
A message box pops up twice with the same text on it: you are NOT home
Actual Result
A message box pops up twice with differen texts on it, first is "you are NOT home", second is "you are home"
Change History (2)
Note: See
TracTickets for help on using
tickets.
Yes, Using query_posts() overrides the current global loop.
AFAIK you should use a custom loop (ie. new WP_Query) instead if you wish to retain THE loop whilst having your own loop.
See also: #9854