Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbp_has_topics() not working properly in my custom theme

  • @berkelmudez

    Participant

    Hi people,

    I basically can’t get to show any topics on a custom theme that I’ve been making.
    I think it has nothing to do plugins, in my custom theme when I call ‘bbp_has_topics()’ it returns the boolean false. But when I switch to the wordpress theme twenty fifteen, I get returned the boolean true and it basically shows the topic correctly, with all plugins turned on.

    However my forums list get displayed correctly, and the topic detail page will only display the topic when I turn off the ‘bbp_show_lead_topic()’ as it by default only shows when that function return true which in my custom theme it doesn’t.

    the function ‘bbp_has_topics()’ basically get influenced or something as soon as I switch to my custom theme. To be honest honest I have no clue what causes this action to influence that those bbp function, I was hoping someone here did.

    Does anyone have any suggestions or have encountered this problem and knows what could possibly cause this problem?

Viewing 10 replies - 1 through 10 (of 10 total)
  • @robin-w

    Moderator

    so where in your theme do you call bbp_has_topics?

    @berkelmudez

    Participant

    Hi, to test what boolean came out I tested bbp_has_topics() in: custom_theme/bbpress/loop-topics.php.
    In my custom theme it returns false and in wp twenty fifteen theme it returns true. Maybe using buddypress has something to do with it?

    @robin-w

    Moderator

    ok, so you have the same loop-topics.pho loaded into both themes?

    @berkelmudez

    Participant

    Yup I have literally copied all the code from ‘loop-topics.php’ in custom theme to the wordpress theme twenty fifteen, where it correctly does return true and topics are shown correctly.
    I must have done something wrong in my custom theme, I just have no idea what the possible causes could be tho.

    It just came to my mind that it might be template php file that bbpress uses, I’ll go check that now.
    I use bbpress in combination with buddypress maybe it can be something with that also.

    @berkelmudez

    Participant

    I finally found what was causing the problem after going through my functions.php.
    Apparantly it was this function that was causing my bbp_topic functions to not function:

    function SearchFilter($query) {
        if ($query->is_search) {
          $query->set('post_type', 'post');
        }
        return $query;
      }
      add_filter('pre_get_posts','SearchFilter');

    After commenting this out everything seems to work perfectly fine now with all topic functions working and displaying correctly now.
    I still don’t know exactly what it is but I probably am not using the $query stuff properly in here. Anyway the problem got much more clear now at least and can be dealt with much better now.

    @robin-w

    Moderator

    @berkelmudez

    Participant

    Wow very nice! The bbpress-fix actually did it! I guess it’s solved it now, thanks!!

    @robin-w

    Moderator

    So I can help others – what version of wordpress are you running?

    @berkelmudez

    Participant

    I am running WordPress 4.4.2

    @robin-w

    Moderator

    Thanks for that – much appreciated !

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar