Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Can\'t I use bp template tags in my own template?


outolumo
Participant

@outolumo

I just went through the default bp-sn-parent theme and harvested all the action hooks beginning with bp_ to a list. Could someone put it to the codex? This list could be useful for people developing their own BuddyPress themes. I hope I didn’t miss anything.

Because these hooks appear in the default BuddyPress theme, some plugin developers might assume their existance in bp-themes. Therefore they should probably exist somewhere in the custom template files. Most of these are are fairly generic and could be filtered into existing themes (e.g. bp_head() could be filtered using wp_head() hook), assuming that the theme you are building on is properly saturated with hooks.

Note that the optionsbar.php, userbar.php and plugin-template.php need to be added to your theme. I don’t know if they could be filtered.

The notable exception being the search-login-bar and nav-items. IMO they shouldn’t be in the BuddyPress template at all. Better solution would be to have functions for search-box & login widget, and insert them to the template using tags for those. This would make them both more reusable – e.g. search-box could be re-used on search and 404 templates – and flexible, allowing to login box to appear separate from the search box. Likewise the nav-menu should be widgetized, i.e. made a function that can be called somewhere from the page.

While not exactly a template tag issue, theme developers should be aware that the buddypress admin bar is by default activated at the wp_footer() as follows:

add_action( ‘wp_footer’, ‘bp_core_admin_bar’, 8 );

I’m gonna try placing the following to the functions.php:

remove_action(‘wp_footer’, ‘bp_core_admin_bar’, 8);

add_action( ‘i_want_it_here_tag’, ‘bp_core_admin_bar’, 8 );

====================================================

header.php

<?php do_action( ‘bp_head’ ) ?> (In the head section.)

<?php do_action( ‘bp_before_search_login_bar’ ) ?>

<?php do_action( ‘bp_login_bar_logged_out’ ) ?>

<?php do_action( ‘bp_login_bar_logged_in’ ) ?>

<?php do_action( ‘bp_search_login_bar’ ) ?>

<?php do_action( ‘bp_after_search_login_bar’ ) ?>

<?php do_action( ‘bp_before_header’ ) ?>

<?php do_action( ‘bp_nav_items’ ); ?>

<?php do_action( ‘bp_header’ ) ?>

<?php do_action( ‘bp_after_header’ ) ?>

<?php do_action( ‘bp_before_container’ ) ?>

====================================================

footer.php

<?php do_action( ‘bp_after_container’ ) ?>

<?php do_action( ‘bp_before_footer’ ) ?>

<?php do_action( ‘bp_footer’ ) ?>

<?php do_action( ‘bp_after_footer’ ) ?>

====================================================

Content wrappers: inside #container, but containing #content.

index.php

<?php do_action( ‘bp_before_blog_home’ ) ?>

<?php do_action( ‘bp_after_blog_home’ ) ?>

single.php

<?php do_action( ‘bp_before_blog_single_post’ ) ?>

<?php do_action( ‘bp_after_blog_single_post’ ) ?>

404.php

<?php do_action( ‘bp_before_404’ ) ?>

<?php do_action( ‘bp_after_404’ ) ?>

archive.php

<?php do_action( ‘bp_before_archive’ ) ?>

<?php do_action( ‘bp_after_archive’ ) ?>

page.php

<?php do_action( ‘bp_before_blog_page’ ) ?>

<?php do_action( ‘bp_after_blog_page’ ) ?>

attachment.php

<?php do_action( ‘bp_before_attachment’ ) ?><

<?php do_action( ‘bp_after_attachment’ ) ?>

links.php

<?php do_action( ‘bp_before_blog_links’ ) ?>

<?php do_action( ‘bp_after_blog_links’ ) ?>

search.php

<?php do_action( ‘bp_before_blog_search’ ) ?>

<?php do_action( ‘bp_after_blog_search’ ) ?>

====================================================

Post wrappers – everything within the Loop. N.B. not every loop is listed here.

index.php, single.php, archive.php, attachment.pgp, search.php

<?php do_action( ‘bp_before_blog_post’ ) ?>

<?php do_action( ‘bp_after_blog_post’ ) ?>

====================================================

Some specific tags allowing to replace the entire loop:

404.php

<?php do_action( ‘bp_404’ ) ?>

search.php

<?php do_action( ‘bp_blog_post’ ) ?>

====================================================

The mandatory Buddypress templates:

optionsbar.php

<?php do_action( ‘bp_before_options_bar’ ) ?>

<?php do_action( ‘bp_inside_before_options_bar’ ) ?>

<?php do_action( ‘bp_inside_after_options_bar’ ) ?>

<?php do_action( ‘bp_after_options_bar’ ) ?>

userbar.php

<?php do_action( ‘bp_before_user_bar’ ) ?>

<?php do_action( ‘bp_inside_before_user_bar’ ) ?>

<?php do_action( ‘bp_inside_after_user_bar’ ) ?>

<?php do_action( ‘bp_after_user_bar’ ) ?>

plugin-template.php

<?php do_action(‘bp_template_content_header’) ?>

<?php do_action(‘bp_template_title’) ?>

<?php do_action(‘bp_template_content’) ?>

=================================

Special templates:

comments.php

<?php do_action( ‘bp_before_blog_comment_list’ ) ?>

<?php do_action( ‘bp_after_blog_comment_list’ ) ?>

<?php do_action( ‘bp_before_blog_comment_form’ ) ?>

<?php do_action( ‘bp_blog_comment_form’ ) ?>

<?php do_action( ‘bp_after_blog_comment_form’ ) ?>

searchform.php

<?php do_action( ‘bp_before_blog_search_form’ ) ?>

<?php do_action( ‘bp_blog_search_form’ ) ?>

<?php do_action( ‘bp_after_blog_search_form’ ) ?>

sidebar.php

<?php do_action( ‘bp_before_blog_sidebar’ ) ?>

<?php do_action( ‘bp_inside_before_blog_sidebar’ ) ?>

<?php do_action( ‘bp_inside_after_blog_sidebar’ ) ?>

<?php do_action( ‘bp_after_blog_sidebar’ ) ?>

More details about how these tags are applied can be found by looking at the files in the bp-sn-parent -theme.

Skip to toolbar