WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Widget Logic Conditional for bbPress (5 posts)

  1. RUBYHAUS
    Member
    Posted 1 year ago #

    So I love Widget Logic and have had great success using it.
    Here is how I use it for specific Categories etc...
    is_category( array( '6', '7', '14' ) ) || (is_single( array( '6', '7', '14' ) ) && in_category( array( '6', '7', '14' ) ) )

    My question is though...
    How can I write up a conditional that only shows the widgets for bbPress on bbPress and does NOT let the bbPress widgets appear on the blog?

    I tried this and does not seem to work.
    bb_is_forum( 'forumName' )

    My Research Thus Far
    This Page looks correct:
    http://hskinrepair.com/forums/forum/forum/

    There are NO "blog" based widgets.

    This Page is incorrect:
    http://hskinrepair.com/category/blog/

    I'm trying to exclude the Forum Widgets but cannot figure this one out as they are not based on Category or Page id's.

  2. RUBYHAUS
    Member
    Posted 1 year ago #

    bb_is_forum( 'myForumNameiCreated' )

    produces a Fatal Error:

    Fatal error: Call to undefined function bb_is_forum() in /nfs/c10/h05/mnt/150010/domains/hskinrepair.com/html/wp-content/plugins/widget-logic/widget_logic.php(270) : eval()'d code on line 1

  3. kuasha42
    Member
    Posted 1 year ago #

  4. RUBYHAUS
    Member
    Posted 1 year ago #

    Thanks Kuasha42. I did see that but wasn't sure what it was as it was MP then I went back after you posted and saw the bb part. Thanks for reposting that link!!!

    Because I named my Forum "forum"... This worked like a champ. I added it to every bbPress widget and now only the bbPress widgets show up on the Forum pages and not on the WordPress Blog pages/categories.

    is_bbpress( 'forum' )

    And this is what all my Blog widgets look like.

    is_category( array( '1' ) ) || (is_single( array( '1' ) ) && in_category( array( '1' ) ) )

    I use arrays so that I can target specific categories and such I want them to be visible on.
    That would look like this:

    is_category( array( '1','8','23' ) ) || (is_single( array( '1','8','23' ) ) && in_category( array( '1','8','23' ) ) )

    There are probably better ways of doing this but this has worked great for me and been more consistent and bullet proof. I also have lots of flexibility doing it this way.

  5. RUBYHAUS
    Member
    Posted 1 year ago #

    I suppose if you have more than 1 Forum Name you could do this too:
    is_bbpress( 'forum','coolforum','anotherforum' )

Topic Closed

This topic has been closed to new replies.

About this Topic