apply js file only to the bbp forum
-
I have been trying to assign some js files only to their respective pages on my site, instead of loading them everywhere and have been successful apart from with my forum area.
in my functions.php file i have tried the following:add_action ('wp_print_scripts', 'deregister_forum_scripts'); function deregister_forum_scripts(){ if ( !is_page('forum') (is_page() && in_array( 19306, get_post_ancestors( get_the_ID() ) ) ) ) { wp_deregister_script('forum-js'); }}
whereby i got the id 19306 from my database by doing:
select ID from wp_posts where post_name = 'forum';
As the page is http://www.apis.de/forum/
The issue is, even if I leave out the second part of the “if” statement (i.e. “is_page()….), it doesn’t work.
I assume this is because my forum is implemented differently to the rest of my site and is not a normal “is_page(….)”.
Can anyone advise here how to target the forum via PHP?
Also, i don’t think i should be using “get_post_ancestors
” but “get_page_children
“. But that is another topic.
- You must be logged in to reply to this topic.