Title: Using is_bbpress()
Last modified: August 18, 2019

---

# Using is_bbpress()

 *  Resolved [tapiohuuhaa](https://wordpress.org/support/users/tapiohuuhaa/)
 * (@tapiohuuhaa)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/using-is_bbpress/)
 * 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 6 years, 9 months ago by [tapiohuuhaa](https://wordpress.org/support/users/tapiohuuhaa/).

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

 *  Thread Starter [tapiohuuhaa](https://wordpress.org/support/users/tapiohuuhaa/)
 * (@tapiohuuhaa)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/using-is_bbpress/#post-11842618)
 * 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](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/using-is_bbpress/#post-11842702)
 * 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](https://wordpress.org/support/users/tapiohuuhaa/)
 * (@tapiohuuhaa)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/using-is_bbpress/#post-11842723)
 * 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.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [tapiohuuhaa](https://wordpress.org/support/users/tapiohuuhaa/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/using-is_bbpress/#post-11842723)
 * Status: resolved