How to load JS and CSS only on specific Pages using is_page()?

If $page_selected returns a string containing the page title, it should work fine. I have tested it and is_page() accepts page title, page ID and the slug.

If you are facing issues, it will be better to store page ID in the database and use it with is_page()

Please refer to https://codex.wordpress.org/Function_Reference/is_page for more details on the possible arguments that can be passed to this conditional statement.

Leave a Comment