Skip Navigation

[Resolved] Expand function to include bootstrap css on specific page

This thread is resolved. Here is a description of the problem and solution.

Problem:

Check current page is specific page with PHP codes.

Solution:

You can use WordPress function is_page().

Relevant Documentation:

https://developer.wordpress.org/reference/functions/is_page/

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by JoshuaJ301 4 years ago.

Assisted by: Luo Yang.

Author
Posts
#1580359

Tell us what you are trying to do?
I'm using a function to deque the bootstrap 4 css on my site and only allow it on specific post types. I'm wondering if this can be expanded to add the css on specific pages. I'm currently using views on pages and they need to use the bootstrap css grid. Because the css is dequed on the site, it is not working properly.
Is there any documentation that you are following?
https://toolset.com/forums/topic/apply-bootstrap-to-specific-pages-using-toolset/
Is there a similar example that we can see?
N/A
What is the link to your site?
hidden link

#1580553

Hello,

You can use WordPress function is_page() to check current page is specific page, for example, add a line just after:

function dequeue_bootstrap_except_twitch_channels(){
    if( is_page(123) ) return; // add this line
...

Please replace 123 with your specific page ID.

More help:
https://developer.wordpress.org/reference/functions/is_page/
Determines whether the query is for an existing single page.

#1581539

Hi Luo,
Thanks so much! This did work.

I was wondering if this works like the array? Can I add multiple pages if I should need to do so in the future?

#1583531

The function is_page() does not support array parameter, so you can add more pages like this:

if( is_page(123) || is_page(456) || is_page(789) ) return; // add this line
#1586115

Thanks Luo! This helped me out a great deal. My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.