Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Code Snippets: Storing plugin theme files in the plugin dir (1.2)

Ok, this particular problem really sucks. You use bp_core_load_template() in a plugin to load a theme file, using the filter ‘bp_located_template’.

If you’re modelling your plugin on the default BuddyPress components, or even the skeleton component, you could use the above to load an index page for your directory, and use a “loop” file to display each item within your directory index page.

However, the whole purposes of the ‘bp_located_template’ filter is that it allows theme authors to override your plugin’s theme file by adding it to their WordPress theme directory. The problem is that you cannot use bp_located_template() to include your loop file (henceforth referred to as a “plugin sub-template”).

Why? Because bp_core_load_template() just sets up the data for the template to load; nothing happens until the WordPress ‘template_redirect’ action is called, which only happens once on page load (.e. when it loads your index page).

Quick fix? After calling bp_core_load_template( ‘plugin/sub-template.php’ ), just call bp_core_do_catch_uri().

Proper fix? Working on it.

bp_core_load_template is not working when trying to load plugin’s sub-templates from within that plugin’s template file(s)

Skip to toolbar