Make your own custom BuddyPress page
-
The title of this post makes it a little hard to grasp what I’m talking about, but in short this is a really quick and easy way to make your own hard coded BuddyPress page without going into the WordPress page admin.
In this example we’re going to make a page called “fun” that you can visit at domain.com/fun.
Put the following In your home theme’s functions.php file…
define('BP_EXAMPLE_SLUG', 'fun');
function bp_show_example_page() {
global $bp, $current_blog;
if ( $bp->current_component == BP_EXAMPLE_SLUG && $bp->current_action == '' ) {
// The first variable here must match the name of your template file below
bp_core_load_template( 'fun', true );
}
}
add_action( 'wp', 'bp_show_example_page', 2 );Now you need to create a fun.php file (mentioned above) in your home theme directory, and inside that file put…
<?php get_header(); ?>
<h3>Hello</h3>
<p>I am an example page.</p>
<?php get_footer(); ?>This could be used to make custom a custom login page, or whatever you’d like…
All we did here was swipe the exact code BP already uses for the /register and /activate pages, and simplify it for our own use.
Have fun!
-
Thanks JJJ for the tip.
I’ve been playing with it and it works for me only if the template page is called fun.php instead of example.php.
Anyway I find it very useful.
Thank you
Robert – the example.php is meant to be replaced with whatever name you’re using for the slug/load_template.
I’m using this to group members/groups/blogs into a community page.
Good stuff, thanks John.
bp_core_load_template( ‘chubacabra’, true );
that would look for chubacabra.php in the home directory, correct?
It does not have to match the slug, I assume?
I like it! So simple!
Can we should sticky this?
@Robert, edited the post to reflect this little typo. Thanks for the catch!
@Toly, you’re correct, but my post was still a little off. Thanks for helping clarify!
@Matt Kern, that is correct. You can also do something like…
bp_core_load_template( 'fun/chubacabra', true );
…if you want to put all your chubacabra files in a directory in your themes root.
@JasonG, we’ve got an awful lot of stickies. I’m going to add it to the Wiki instead :cough:
@everyone, this method shouldn’t change much by the time BP1.1 comes around, but keep an eye out just in case.
I’ve tried this, but can’t seem to get it to work. I put the function, defined above, in the functions.php page in the BP theme directory I’m using (which is the default bpmember) and put the help.php page (that’s what my page is called) into the same folder (is this correct). I think my problem is that I’m not sure when people say “home theme’s functions.php file” if they mean the bpmember folder (since that is my home theme) and if the “home theme directory” is again the bpmember folder (again, since that’s my home theme). Am I just getting this all confused?
thanks
@allenweiss, both of the files need to go in your active WordPress HOME theme, not your bpmember theme.
thanks..so if I’m using, say, carrington-blog for my wordpress home theme, then it would go in the carrington-blog directory? If so, I just tried that and it always results in a page not found. Am I doing something wrong? Note, I have the code in the functions.php file (which is in the carrington-blog folder) and the file it points to in that folder as well – as per your instructions…thanks
How would I then create a new menu tab for the new page?
we put this code in /wp-content/themes/bp-sn-parent/functions.php and created a page in the same directory called dashboard.php
is there a reason why we cant navigate to the dashboard.php?
// creates custom page
define('BP_DASHBOARD_SLUG', 'dashboard');
function bp_show_dashboard_page() {
global $bp, $current_blog;
if ( $bp->current_component == BP_DASHBOARD_SLUG && $bp->current_action == '' ){
// The first variable here must match the name of your template file below
bp_core_load_template( 'dashboard', true );
} }
add_action( 'wp', 'bp_show_dashboard_page', 2 );
//
end custom page
any help is appreciated!
Are you trying to access…
http://domain.com/dashboard/
or
http://domain.com/dashboard.php
Otherwise, it looks about right?
very cool! adding this right now!
Hey John,
I’m trying to access either! neither seems to work!
Does this also work for child themes? I get at example.com/about
This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.
Hey Guys, I still can’t get this to work? I am on bp ver 1.1
Maybe things got changed in the update that would effect the way this works? I really need to have custom pages for this to work for my site. Again, to recap, here is what I have done:
put the below code into : (wordpress mu and buddy press are installed into subfolder)
mysite/subfolder/wp-content/themes/bp-sn-parent/functions.php and created a page in the same directory called dashboard.php
CODE:
// creates custom page
define('BP_DASHBOARD_SLUG', 'dashboard');
function bp_show_dashboard_page() {
global $bp, $current_blog;
if ( $bp->current_component == BP_DASHBOARD_SLUG && $bp->current_action == '' ){
// The first variable here must match the name of your template file below
bp_core_load_template( 'dashboard', true );
} }
add_action( 'wp', 'bp_show_dashboard_page', 2 );
//
end custom page
URGENT: Need to figure this out!!!!
Try putting that into a file /plugins/bp-custom.php.
Putting it in plugins/bp-custom.php has not helped either. All I ever get is page not found.
define('BP_ABOUT_SLUG', 'about');
function bp_show_about_page() {
global $bp, $current_blog;
if ( $bp->current_component == BP_ABOUT_SLUG && $bp->current_action == '' ) {
// The first variable here must match the name of your template file below
bp_core_load_template( '/_inc/pages/about', true );
}
}
add_action( 'wp', 'bp_show_about_page', 2 );the file is located in _inc/pages/about.php
Can anyone see anything else?
It probably needs to be in the functions.php of the parent theme, and the template file itself should also probably be in the parent theme as well. I haven’t tested it any other way as I haven’t needed that particular kind of setup.
I could really benefit from learning how to do custom pages in 1.1 as well. Has anybody figured this out yet?
hey guys, i REALLY need to be able to do this. i followed all the instructions exact but it’s not showing up, just getting the home page. I’m wondering if it has to do with putting the SLUG in the navigation code? anybody have any ideas?? i even put the services.php page i created in every directory, still no dice. i worked with the bp-sn-parent/functions.php, put the services.php in bp-sn-parent, themes, themes/mytheme, and wp-content.
dosn’t work for me neither.
i added the code to functions.php and the fun file in “bp-sn-parent” and the child theme (and both), system alsways says “not found”
It seems this nice little function isn’t working anymore with Buddypress 1.1, at least i tried the code in every possible location (funtions.php, bp-custom.php) without success.
It would be great if we could figure out why, because it was so simple and useful!
i would totally love this feature to work!
I think I’ll make this into a downloadable plugin in the WP repo to try and ease some of the pain.
@John James Jacoby: But you can confirm that it still works for BP 1.1?
- The topic ‘Make your own custom BuddyPress page’ is closed to new replies.