0

I posted a question in bbforum 2 months ago without success, https://bbpress.org/forums/topic/enque-bbpress-scripts-only-on-forum-pages/

I am working on a theme and need to deque all bbpress scripts and enque my own if I am on forum pages. This is what I used to start with

if( !is_admin() ){ 
    /**
     *  Replace bbpress style with our own
     *  @internal
     */
    function _thz_action_bbpress_style() {

        wp_dequeue_style( 'bbp-default' );

        if (is_bbpress()){

            wp_enqueue_style( THEME_NAME. '-bbpress' ); 

        }


    }

    if (function_exists('is_bbpress')){
        add_action( 'wp_enqueue_scripts', '_thz_action_bbpress_style' );
    }

Just trying to find a conditional that actualy works.

is_bbpress()

does not work if you have a forum homepage via

[bbp-forum-index]

shortcode

According to the docs is_bbpress() should detect it but it does not.

Does anyone know a working solution?

I am trying to avoid , has_shortcode($page_content, 'bbp-forum-index') since it will have to be used on all pages which in fact kills performance for no reason.

3
  • Try this workaround pastebin.com/QLcBVjT7
    – Ismail
    Commented Sep 9, 2016 at 21:23
  • @SamuelElh that places the stylesheet at the bottom of the page instead in head
    – Benn
    Commented Sep 10, 2016 at 7:29
  • You can always filter is_bbpress, I tried something pastebin.com/Eyeqimwt but for early usage (e.g wp is not loaded) it won't work as $wp_query->queried_object goes null.
    – Ismail
    Commented Sep 10, 2016 at 11:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.