• Resolved tapiohuuhaa

    (@tapiohuuhaa)


    Why I could not use this condition:

    if(is_bbpress()){
    add_action( ‘wp_head’, function () { ?>
    <style id=”foorumi”>

    Site crashed, when I try to use the if-statement with wp_head function.
    My idea was to output CSS for bbPress only on forum area. If I could limit it with PHP, browsers would not need even get the CSS at all.

    Correspond I would like to use if statement to prevent CSS rendering, which bbPress doesn’t need at all.

    I tried priorities 0,10 and some over 10.

    if(is_bbpress()) works fine with my own functions.

    • This topic was modified 5 years, 7 months ago by tapiohuuhaa.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    I tryed another method. This works:

    function myCSSforbbPress(){
    if(is_bbpress()){
    $CSS='<style>…</style>’;
    echo $CSS;
    }
    add_action( ‘wp_head’, ‘myCSSforbbPress’);

    Why I must use in this case my own function?

    Plugin Author Shea Bunge

    (@bungeshea)

    It looks like snippets are running before the is_bbpress() template tag has been defined.

    You need to make sure you only use it inside an action or filter hook to make sure that it has been defined first.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    I just wonder why is_bbpress() works with my own function, which is called by
    add_action( ‘wp_head’, ‘myCSSforbbPress’);

    In my mind in both cases is_bbpress() is defined before using it with add_action. Anyway using own function solved the problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using is_bbpress()’ is closed to new replies.