Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6153 closed defect (bug) (fixed)

is_page AND is_single both set on page footer (reproducable

Reported by: juggledad's profile juggledad Owned by: r-a-y's profile r-a-y
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)

6153.01.patch (763 bytes) - added by r-a-y 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 @r-a-y
10 years ago

  • Keywords has-patch added

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 the is_page variable.

01.patch removes the is_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.

Last edited 10 years ago by r-a-y (previous) (diff)

@r-a-y
10 years ago

#2 @r-a-y
10 years ago

  • Version changed from 2.1 to 1.9.2

This ticket was mentioned in Slack in #buddypress by r-a-y. View the logs.


10 years ago

#4 @r-a-y
10 years ago

  • Milestone changed from Awaiting Review to 2.3

Will commit in 2.3.

#5 @r-a-y
10 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 9484:

Theme compat: Streamline toggling of $wp_query properties during theme compatibility.

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.

However, if we're on a regular WordPress page, only the is_page property
returns true. Therefore, this commit removes the is_single overrides,
which fixes issues with the comments template rendering in some themes
like Atahualpa.

Fixes #6153.

#6 @r-a-y
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.

Note: See TracTickets for help on using tickets.