Search code examples
wordpresslegacybuddypress

Buddypress template hierarchy is not being used


I am updating an installation of buddypress (1.5) to the most recent version (2.1.1). I have updated the files and am now trying to update the theme to use the template hierarchy pattern.

For this I created the following directory structure within my theme:

my-theme/
  buddypress/
    groups/
      index-directory.php

index-directory.php contains a single die('debug') statement for testing.

If I copy this buddypress directory into the twentyfourteen directory and activate that theme, I am seeing the debug message when I'm on the group listing page. However, when I use my custom theme, the message is not showing up.

This tells me that the template hierarchy is not being applied on my theme. Why could that be?

I suspect that somehow my theme is being treated as a legacy theme, I don't understand why though. I commented out the whole functions.php to make sure it's not because of aynthing in there. The header comment in the style.css does not contain anything special either.

Any help on this? Thanks.


Solution

  • The problem was my own mistake. Our theme stylesheet had a Template: bp-default in it. I didn’t notice it at first because our theme is named similarly and my mind read it as the title of our theme. If I remove it, my templates are included.

    For anyone stumbling on this problem in the future, here are the reasons why the template hierarchy could be deactivated by Buddypress:

    Theme compat is disabled when a theme meets one of the following criteria:

    1) It declares BP support with add_theme_support( 'buddypress' )

    2) It is bp-default, or a child theme of bp-default

    3) A legacy template is found at members/members-loop.php. This is a fallback check for themes that were derived from bp-default, and have not been updated for BP 1.7+; we make the assumption that any theme in this category will have the members-loop.php template, and so use its presence as an indicator that theme compatibility is not required

    https://buddypress.org/support/topic/default-theme-is-still-showing/