Advertisement
Guest User

Loop pagination inside a buddypress profile tab

a guest
Aug 23rd, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. function my_test_setup_nav() {
  2.     global $bp;
  3.     // Change the order of menu items
  4.     //$bp->bp_nav['messages']['position'] = 100;
  5.  
  6.     // Remove a menu item
  7.     $bp->bp_nav['blogs'] = false;
  8.    
  9.     // Change name of menu item
  10.     // $bp->bp_nav['groups']['name'] = ‘community’;
  11.    
  12.     // Menú PUBLICACIONES
  13.      //name, slug, screen, position, default subnav
  14.         bp_core_new_nav_item( array(
  15.         'name' => __( 'Publicaciones' ),
  16.         'slug' => 'publicaciones',
  17.         'screen_function' => 'funcion_tab_publicaciones',
  18.         'position' => 40,
  19.         'default_subnav_slug' => 'mis_publicaciones'
  20.         ) );
  21. }    
  22. /* Add the subnav items to the profile */
  23. // name, slug, parent_url, parent slug, screen function
  24. bp_core_new_subnav_item( array( 'name' => __( 'Home' ), 'slug' => 'mis_publicaciones', 'parent_url' => $bp->loggedin_user->domain, 'parent_slug' => 'mis_publicaciones', 'screen_function' => 'funcion_tab_publicaciones' ) );
  25.  
  26. function funcion_tab_publicaciones() {
  27.     //add title and content here - last is to call the members plugin.php template
  28.     add_action( 'bp_template_title', 'funcion_tab_publicaciones_title' );
  29.     add_action( 'bp_template_content', 'funcion_tab_publicaciones_content' );
  30.     bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
  31. }
  32. function funcion_tab_publicaciones_title() {echo 'Mis Publicaciones'; }
  33. function funcion_tab_publicaciones_content() {
  34.     global $post;
  35.     global $paged; // current paginated page
  36.  
  37.     // arguments, adjust as needed
  38.     $args = array(
  39.         'post_type'      => 'post',
  40.         'posts_per_page' => 4,
  41.         'post_status'    => 'publish',
  42.         'paged'          => get_query_var( 'paged' )
  43.     );
  44.  
  45.     /*
  46.     Overwrite $wp_query with our new query.
  47.     The only reason we're doing this is so the pagination functions work,
  48.     since they use $wp_query. If pagination wasn't an issue,
  49.     use: https://gist.github.com/3218106
  50.     */
  51.     global $wp_query;
  52.     $wp_query = new WP_Query( $args );
  53.  
  54.     if ( have_posts() ) :
  55.         echo '<ul>';
  56.         while ( have_posts() ) : the_post();
  57.  
  58.             echo '<li>' . get_the_title() . '</li>';
  59.  
  60.         endwhile;
  61.         echo '</ul>';
  62.         do_action( 'genesis_after_endwhile' );
  63.     endif;
  64.  
  65.     wp_reset_query();
  66. }
  67. add_action( 'bp_setup_nav', 'my_test_setup_nav' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement