#6153 closed defect (bug) (fixed)
is_page AND is_single both set on page footer (reproducable
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.3 | Priority: | normal |
Severity: | normal | Version: | 1.9.2 |
Component: | Core | Keywords: | has-patch |
Cc: | juggledad |
Description
Using TwentyFifteen, at the end of page.php both is_page() and is_single are true. To repeoduce this do the following
1) clean install of WP
2) create a page called 'Members' - set 'Dicussion' to allow comments
3) edit twentyfifteen's page.php and replace it with the following (it just has a bunch of echo's added)
<?php /** * The template for displaying pages * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages and that * other "pages" on your WordPress site will use a different template. * * @package WordPress * @subpackage Twenty_Fifteen * @since Twenty Fifteen 1.0 */ get_header(); ?> <?php echo '1 is_single()='.is_single().'<br>'; ?> <?php echo '1 is_page()='.is_page().'<br>'; ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php // Start the loop. while ( have_posts() ) : the_post(); echo '2 is_single()='.is_single().'<br>'; echo '2 is_page()='.is_page().'<br>'; // Include the page content template. get_template_part( 'content', 'page' ); echo '3 is_single()='.is_single().'<br>'; echo '3 is_page()='.is_page().'<br>'; // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; echo '4 is_single()='.is_single().'<br>'; echo '4 is_page()='.is_page().'<br>'; // End the loop. endwhile; ?> </main><!-- .site-main --> </div><!-- .content-area --> <?php echo '5 is_single()='.is_single().'<br>'; ?> <?php echo '5 is_page()='.is_page().'<br>'; ?> <?php get_footer(); ?>
4) add the page to a menu and set the menu as the primary menu
5) view the page
in each set of echo's you will see
n is_single()=
n is_page()=1
6) install BuddyPress (this is a problem in 2.1 and 2.2 Beta 2)
7) in dashboard->settings->buddypress->pages set the Members to the Members page
8) go view the page
at this point you will see that the first set of echo's - just after the get_header() - will be
1 is_single()=
1 is_page()=1
the second set of echo's - right after the 'while ( have_posts() ) : the_post();' will be
2 is_single()=
2 is_page()=1
the third set of echo's - right after the 'get_template_part( 'content', 'page' );' will be
3 is_single()=
3 is_page()=
the forth set of echo's - right before the ' End the loop.' will be
4 is_single()=
4 is_page()=
and the fifth set of echo - right before the 'get_footer();' - will be
5 is_single()=1
5 is_page()=1
something is clearly not proper.
Attachments (1)
Change History (7)
This ticket was mentioned in Slack in #buddypress by r-a-y. View the logs.
10 years ago
#5
@
10 years ago
- Owner set to r-a-y
- Resolution set to fixed
- Status changed from new to closed
In 9484:
#6
@
10 years ago
Ugh... ignore the commit message typo. It's missing a sentence.
Should read:
#5339 attempted to prevent
comments_template()
from showing on BuddyPress pages by toggling the $wp_query is_single and is_page properties to false during theme compatibility and back to true after the loop.
Thanks for the bug report, juggledad, and for the detailed debug statements.
See #5339 where this change was originally made. The bug occurred when resetting the
is_single
variable to true, which is wrong. Based on your findings, we should only be resetting theis_page
variable.01.patch
removes theis_single
calls, which should fix this issue.Thanks again!
Devs: Since this wasn't made clear in the ticket description, this patch fixes issues with the
comments_template()
call showing on some themes like Atahualpa.I think this would be nice to fix for 2.2, but it's not a regression since this bug was introduced in 1.9.2.