Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: [pulperia] My posts
- Plugin URI:
- Description: Post list from the displayed user as author
- Version: 1.0
- Author: GGsalas
- Author URI: http://ggsalas.com
- */
- function bp_content_setup_nav1() {
- global $bp;
- bp_core_new_nav_item( array(
- 'name' => 'Myposts',
- 'slug' => 'myposts',
- 'parent_url' => $bp->displayed_user->domain,
- 'parent_slug' => $bp->profile->slug,
- 'screen_function' => 'mis_publicaciones',
- 'position' => 70,
- 'default_subnav_slug' => '/',
- ));
- }
- add_action( 'bp_setup_nav', 'bp_content_setup_nav1',100 );
- function mis_publicaciones() {
- add_action( 'bp_template_content', 'mis_publicaciones_content' );
- bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
- }
- function mis_publicaciones_content() {
- global $post;
- global $bp;
- $paged = ( isset( $_GET['pubs'] ) ) ? $_GET['pubs'] : 1;
- $args = array(
- 'post_type' => 'post',
- 'post_status' => 'publish',
- 'posts_per_page' => 2,
- 'author' => bp_displayed_user_id(),
- 'paged' => $paged
- );
- /**
- * Loop
- */
- // The Query
- $wp_query = new WP_Query( $args );
- // The Loop
- if ( $wp_query->have_posts() ) {
- while ( $wp_query->have_posts() ) {
- $wp_query->the_post();
- ?>
- <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
- <?php
- }
- echo ggsalas_profile_pagination( $wp_query );
- }
- }
- function ggsalas_profile_pagination( $wp_query ) {
- $profile_page_links = paginate_links( array(
- 'base' => @add_query_arg('pubs','%#%'),
- 'format' => '?pubs=%#%',
- 'total' => ceil( (int) $wp_query->found_posts / (int) get_query_var('posts_per_page') ),
- 'current' => (int) get_query_var('paged'),
- 'show_all' => true,
- 'type' => 'plain'
- ));
- // Output pagination
- return $profile_page_links;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement