Opened 12 years ago
Closed 8 years ago
#4328 closed enhancement (fixed)
Using a WP custom page template for a BP component's page
Reported by: | modemlooper | Owned by: | |
---|---|---|---|
Milestone: | 2.2 | Priority: | normal |
Severity: | major | Version: | 1.5 |
Component: | Core | Keywords: | |
Cc: | mercijavier@… |
Description
I was trying to create a custom page template but no matter what BP is using the activity loop instead. If you do not have a posts loop on the page it seems to reject anything else. Check out images below of screen shots of the page and page template
Attachments (2)
Change History (17)
#1
@
12 years ago
link to the page showing the activity loop http://dev.taptappress.com/buzz
#2
@
12 years ago
- Keywords reporter-feedback added
- Version changed from 1.5.6 to 1.5
Are you trying to override a BP component's directory page with a custom page template?
If so, you can't based on this. A workaround is just to modify the activity directory index template in your theme - /activity/index.php.
Update: I guess you could filter 'bp_activity_screen_index' and tell WP to use your custom page template if one exists. Sounds like a good enhancement!
#3
@
12 years ago
- Summary changed from BP overrides page templates 1.5.6 to Using a WP custom page template for a BP component's page
- Type changed from defect (bug) to enhancement
#4
@
12 years ago
No not at all. My original ticket was correct, not this one. When you create a WP page template it does not work anymore with BP. The only thing that will work is a page template with the WP post loop. If you try to create a custom loop is disregards any code and displays the activity loop instead. Can i tag this WTF? LOL
Ray, your suggestion would be a killer idea for theme developers to include custom template files that are choosable like page templates. +10,000
Do I need to repost my ticket since this one was changed to something else? Or can you change the title back to select the issue?
#5
@
12 years ago
- Keywords dev-feedback added
I spent a little bit of time to implement this and it works!
Here's the code snippet:
/** * On the WP page dashboard, if you set a custom page template for a BP * component page, let BP know of it and use it! */ function ray_use_custom_page_template_for_bp_component_index( $template ) { // see if a custom page template exists for the BP component page $custom_template = get_page_template_slug(); // if no custom template, return the default one if ( empty( $custom_template ) ) return $template; // return our custom page template; we strip the extension because bp_core_load_template() requires it return ( str_replace( '.php', '', $custom_template ) ); } add_filter( 'bp_activity_screen_index', 'ray_use_custom_page_template_for_bp_component_index' ); add_filter( 'bp_blogs_screen_index', 'ray_use_custom_page_template_for_bp_component_index' ); add_filter( 'bp_members_screen_index', 'ray_use_custom_page_template_for_bp_component_index' ); add_filter( 'bp_forums_template_directory_forums_setup', 'ray_use_custom_page_template_for_bp_component_index' ); add_filter( 'groups_template_directory_groups', 'ray_use_custom_page_template_for_bp_component_index' );
Core devs: Not sure where to put this in core. I was thinking of adding the function to bp-core-functions.php
. Then, adding the applicable filter to each component's bp-COMPONENT-filters.php
. Let me know what you think.
get_page_template_slug()
does use a few DB queries though - get_post()
, get_post_meta()
- just something to think about.
The code snippet could be released as a tiny plugin as well.
#6
@
12 years ago
- Keywords dev-feedback removed
- Milestone changed from Awaiting Review to Future Release
Not sure if we'll want/need to do this when we put theme compatibility into BP, but moving to the future release milestone for review at that point in time.
#8
@
12 years ago
+1 for bp-default theme especially as many are using only bp-default child themes in their installs. I do :-)
#10
@
12 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Not fixed yet as not committed into BuddyPress. Related ticket is #4639
#11
in reply to:
↑ 9
@
12 years ago
Replying to modemlooper:
Please add a comment in the ticket when making changes to it, otherwise it's impossible to know what your intentions were at the time.
#13
@
10 years ago
- Keywords reporter-feedback removed
I just closed #5686 as a duplicate.
I figured that theme compat was fixing this, no?
Theme compatibility does not address this. My code above works on bp-default installs.
However, imath's code in ticket:3741#comment:27 (the second part) would address this for theme compatibility.
choosing page template in admin