The documentation on is_page(), when you scroll down, has some great examples of how to use it:
// When any single Page is being displayed.
is_page();
// When Page 42 (ID) is being displayed.
is_page( 42 );
// When the Page with a post_title of "Contact" is being displayed.
is_page( 'Contact' );
// When the Page with a post_name (slug) of "about-me" is being displayed.
is_page( 'about-me' );
/*
* Returns true when the Pages displayed is either post ID 42,
* or post_name "about-me", or post_title "Contact".
* Note: the array ability was added in version 2.5.
*/
is_page( array( 42, 'about-me', 'Contact' ) );
Note how it’s just the slug, not the URL of the page, and it only works for the page
post type, whereas a category is something else (a taxonomy).
To do what you want, you may want to get the complete URL of a page, including the query string. (According to this post) you can do this:
global $wp;
$page_url = add_query_arg( $wp->query_vars, home_url( $wp->request ) );
Then you can run comparisons on $page_url
, look for strings inside of it with stristr()
, etc.
One thing that might be helpful about debugging and working with WordPress code:
If I’m not sure about how a function works, I Google for (function_name) wordpress
— the top result is typically the WordPress developer guide, which tells me what the function does, the parameters it accepts, and sometimes even has examples down below
You may have done that, but I thought to mention it!