Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is buddypress overriding the template filter?


  • enderpal444
    Participant

    @enderpal444

    Im trying to use a theme specifically for mobile devices so I filter the “template” and “stylesheet” but only the stylesheet is filtering for mobile devices. So the only reason I can think of is that buddypress is keeping the filter from applying somehow. I use the wordpress function wp_is_mobile to do it like this.

    add_filter( 'template', 'my_mobile_template', 99999, 1);
    function my_mobile_template($template){
    if(wp_is_mobile())
    return 'MobileThemeBeta';
    return $template;
    }
    add_filter( 'stylesheet', 'my_mobile_stylesheet', 999999, 1);
    function my_mobile_stylesheet($stylesheet){
    if(wp_is_mobile())
    return 'MobileThemeBeta';
    return $stylesheet;
    }

    So any idea why only the stylesheet is filtering?

Viewing 4 replies - 1 through 4 (of 4 total)

  • Roger Coathup
    Participant

    @rogercoathup

    Buddypress processes a number of urls and loads the templates directly. Do a search on load_template in the BP files


    enderpal444
    Participant

    @enderpal444

    @rogercoathup How would you change it to make it work?


    enderpal444
    Participant

    @enderpal444

    @djpaul @boonebgorges Could you give this a quick look. I tried adding theme root and theme root uri but now it doesnt even load the stylesheet. So I have this in total to try and load my “MobileThemeBeta” for mobile browsers.

    `add_filter( ‘template’, ‘my_mobile_template’, 99999, 1);
    function my_mobile_template($template){
    if(wp_is_mobile())
    return ‘MobileThemeBeta’;
    return $template;
    }

    add_filter( ‘theme_root’, ‘theme_root’, 99999, 1 );
    function theme_root( $root_path ) {
    if (wp_is_mobile())
    return ‘MobileThemeBeta’;
    return $root_path;
    }

    add_filter( ‘theme_root_uri’, ‘theme_root_uri’, 99999, 1 );
    function theme_root_uri( $root_url ) {
    if (wp_is_mobile())
    return ‘MobileThemeBeta’;
    return $root_url;
    }

    add_filter( ‘stylesheet’, ‘my_mobile_stylesheet’, 999999, 1);
    function my_mobile_stylesheet($stylesheet){
    if(wp_is_mobile())
    return ‘MobileThemeBeta’;
    return $stylesheet;
    }`


    Roger Coathup
    Participant

    @rogercoathup

    Take a look at the bp_core_load_template() function — it gives you some filters, e.g. bp_located_template and bp_load_template, that you could try working with.

    It’s a specialist piece of development, you’ll have to read through that code and work out how to apply to your specific situation.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Is buddypress overriding the template filter?’ is closed to new replies.
Skip to toolbar