Skip to:

is_page no longer works, how do I find out which page user is in

  • celsosoares


    I really can’t understand why is_page no longer works in some buddypress pages, it was a very simple and elegant way of finding out what page you’re on. Can someone help me with this:

    I WANT:
    1. If the current page is X
    2. Display a certain piece of code, or change some css styling

    REALLY, that’s it!!!!!!

    Here’s an example that still works:

    <?php if ( is_home() ) : ?>
        <style>.homepage i {color:#ffd647 !important;}</style>
    <?php endif; ?>

    Here’s an example that no longer works:

    if ( is_page( 'forums' )) : ?>
        <style>.homepage i {color:#ffd647 !important;}</style>
    <?php endif; ?>

    The only difference between those two that I can find is that in the second example I went into a buddypress page.

    I want to use this sort of function in a granular level, so for instance if the current page slug is , I want to be able to call something like if ( is_page( ‘some-forum’ ))

    Hope that makes sense. Maybe there’s something wrong with my code as I’m not a programmer, but THIS IS SUCH A BASIC FUNCTION, why isn’t it better documented????????????

    Pls help!!

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

  • r-a-y


    You shouldn’t rely on PHP conditionals for CSS targeting.

    Use your browser’s developer console and check the various body CSS classes and then target the ones you want to use in your CSS stylesheet.

    Why not use something like?

    body.forums .YOUR-SELECTOR {color:red !important;}

    If you must use PHP conditionals, use the ones that BuddyPress provides:

    View the list of functions in that file for all the ones you can use.



    YES I KNOW how to use CSS and where it should go, the css was an example of something that would go into the “if then” section, there are many things I want to use the function for (as I explained in the part that said “VERY IMPORTANT NOTE”).

    Can you give me a PRACTICAL example for how I could do this:
    DO Y

    For instance, using this from the link you provided:

    function bp_is_forums_component() {
       return (bool) bp_is_current_component( 'forums' );

    How do I convert this into something like..
    if bp_is_current_component( ‘forums’ ) && the page slug is X {
    do something

    thanks in advance



    You mention forums specifically.

    If that is the case, you should use bbPress conditional functions.

    See this page for more details:

    bbPress Conditional Tags

    If you have more questions, post on the bbPress forums as BuddyPress is not bbPress:

    – BuddyPress = community
    – bbPress = forums



    Thanks for your help! What is I’m in the user page? Or the messages page? Can you post an example of how it would work there? Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar