Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change the ‘overloading template’ location for the BP templates.


  • Andrew
    Participant

    @snd26

    Does anyone know how I can setup a directory in my custom plugin to use for overloading BP templates?

    Theme Compatibility & Template Files

    By default, you can modify any BuddyPress templates by copying it over from:

    /bp-templates/bp-legacy/buddypress/

    To:

    themes/my-theme/buddypress/

    But how do you change (and rename) the location:

    themes/my-theme/buddypress/

    to:

    plugins/my-plugin/templates/

    As there are a few reasons I would prefer overloading BP templates in my custom plugin. Any help appreciated.

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

  • Andrew
    Participant

    @snd26

    I’ve almost got it working:

    function cm_load_template_filter() {	 
    	bp_register_template_stack( 'cm_get_template_location');
    }
    add_filter( 'bp_located_template', 'cm_load_template_filter');	
    	
    function cm_get_template_location() {
    	return dirname( __FILE__ ) . '/templates/';
    }

    This works most of the time but it doesn’t work in a few areas such as when I click load more to load more activity items. What else do I need to do to add to this code?


    shanebp
    Moderator

    @shanebp

    You are registering your stack in a filter and overloading all templates.
    I’m not sure if this will solve your Load More issue, but have you tried this approach?

    Template Overload from a Plugin


    Andrew
    Participant

    @snd26

    That did it.

    I was looking for a while how to do this but I must of missed that page.

    Thanks @shanebp

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change the ‘overloading template’ location for the BP templates.’ is closed to new replies.
Skip to toolbar