Skip to:
Content
Pages
Categories
Search
Top
Bottom

is_page() does not work on BP pages


  • juggledad
    Participant

    @juggledad

    Why do BP pages not reply with a 1 if you use is_page()?

    for example – activate twentytwelve and edit content-page.php and add the following before line 11 (the <article id=…)
    <?php echo 'is_page()='.is_page().'<br>'; ?>
    on any page BUT a BP page it reruens a 1 and it returns a null for bBP pages.

    Are BP ‘pages’ not really pages? Why does the is_page() function not work?

Viewing 14 replies - 1 through 14 (of 14 total)

  • Henry
    Member

    @henrywright-1

    The terminology is important here. WordPress ‘pages’ shouldn’t be confused with the more loosely termed web ‘page’. Although BP ‘pages’ are webpages, they aren’t WordPress pages so is_page() isn’t going to work *most of the time*. The exception is register, activate etc.

    For a list of template tags you can use with BP ‘pages’ take a look at:

    Template Tag Reference


    juggledad
    Participant

    @juggledad

    I add the coode in post 1 to twentytwelve
    I create a page in WordPress and call it ‘my-members’
    I view the page
    is_page() returns ‘1’
    I install and activate buddypress
    I ‘Associate a WordPress Page with each BuddyPress component directory.’ and set members pointing at ‘my members’
    I view the page
    is_page() now returns null

    I don’t know about you, but to me this seems like a bug in buddypress


    Henry
    Member

    @henrywright-1

    Just some observations

    1. ‘my members’ isn’t the same as ‘my-members’
    2. <?php echo 'is_page()='.is_page().'<br>'; ?> – why are you doing this?

    I don’t know about you, but to me this seems like a bug in buddypress

    There may well be a bug in BuddyPress – but I can’t tell that from the code and info you’ve posted.


    juggledad
    Participant

    @juggledad

    the ‘my-members’ / ‘my members’ was a typo – it is the same WordPress page
    <?php echo 'is_page()='.is_page().'<br>'; ?> – why are you doing this?

    why, to demonstrate the issue. this is something you can do in 5 minutes to reproduce an issue I am seeing in a theme. Instead of pointing to the theme in question, I’ve shown the ‘bug’ in twentytwelve so anyone can reproduce it.


    modemlooper
    Moderator

    @modemlooper

    BP overrides WP a bit. If you use bp_is_current_component('activity') it works on BP pages. This is something that needs to be fixed now that BP uses any theme.


    Henry
    Member

    @henrywright-1

    Ah right, I see what you’re doing.

    ‘my-members’ is no longer a WP page at the moment you point your BP members directory at ‘my-members’. Is that what you’re saying is a bug?


    juggledad
    Participant

    @juggledad

    ‘my-members’ is no longer a WP page? Hmmm it still shows up in the page editor, so yes I would call that a bug. Why do you have to associate a WP page with a BP component directory?

    bottom line, if BP is going to work with any theme then when a page is displayed, the is_page() should work.


    juggledad
    Participant

    @juggledad

    in addition, if I change the page name and slug in the WP page editor, BP recognizes it…so BP is tied to the page…


    juggledad
    Participant

    @juggledad

    as a matter of fact, if I was to set the page as the WP ‘front_page’ the function is_front_page() returns null

    one additional note: in BP 1.7.1 is_page() returned a ‘1’


    juggledad
    Participant

    @juggledad

    one last thought. If BP is going to work with ‘any’ theme, then if I make a BP page my front page (the reason doesn’t matter) then
    1) is_front_page() should also return a ‘1’, but it doesn’t.
    2) the classes on the <body> should return

    home-page home page page-id-nnnn page-template-default

    in addition to the BP classes

    if I had decided to style my front page blue using

    body.home-page {background-color: blue;}

    and then activating BP should not ignore that CSS, but it will the way things stand now.


    Henry
    Member

    @henrywright-1

    @juggledad

    Thanks for explaining in more detail. If you feel this is a bug, you can submit a ticket on Trac

    Trac is the best place to follow the development process and submit bug reports.


    modemlooper
    Moderator

    @modemlooper

    This will probably get fixed in 2.0 version

    https://buddypress.trac.wordpress.org/ticket/4954


    Henry
    Member

    @henrywright-1

    @modemlooper I have a feeling that ticket will fix quite a few outstanding bugs!


    juggledad
    Participant

    @juggledad

    Just for reference, I opened an issue for this: https://buddypress.trac.wordpress.org/ticket/5307

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘is_page() does not work on BP pages’ is closed to new replies.
Skip to toolbar