Pagination gives error on buddypress tab
-
Hi, I have created a plugin to display a new tab on the user profile. This tab, display all the posts that have the displayed user as author.
The problem I have is the pagination, on
/posts/page/2/
I get “Oops! That page can’t be found.”The plugin I use is this: http://pastebin.com/UwUjFvgX
Thanks and best regards.
-
Untested but try this:
Replace your paginate call with this:
echo ggsalas_profile_pagination( $wp_query );
And add this function to your plugin:
function ggsalas_profile_pagination( $wp_query ) { $profile_page_links = paginate_links( array( 'base' => esc_url( add_query_arg( 'pubs', '%#%' ) ), 'format' => '', 'total' => ceil( (int) $wp_query->found_posts / (int) get_query_var('posts_per_page') ), 'current' => (int) get_query_var('paged'), ) ); return $profile_page_links; }
Hi @shanebp I have tested your code. I need remove the echo because gives an error.
This is the modified code, but have same error: http://pastebin.com/emdJv4F6
Thanks for your help
Maybe this is clearer:
Replace this:
$big = 999999999; // need an unlikely integer echo paginate_links( array( //etc ));
With this:
echo ggsalas_profile_pagination( $wp_query );btw – you don’t need any of the 3 globals you’re including.
Hi @shanebp
Sorry. I have added the modifications. Now I can’t see any pagination links, and if I try go to /page/2 get same “page not found” message.
This is the code: http://pastebin.com/m2RzyJ4j
try:
$paged = ( isset( $_GET['pubs'] ) ) ? $_GET['pubs'] : 1;
Hi @shanebp
Have same result with http://pastebin.com/tBcTSmMn
I see some issues in your function for adding the tab.
Review this gist and note the differences.
Also don’t use ‘posts’ as a slug, try:
'slug' => 'myposts',
Hi @shanebp
I have modified my plugin with
'parent_url' => $bp->displayed_user->domain, 'parent_slug' => $bp->profile->slug,
And remove the title of the tab.
But still I can’t get the pagination working
Hi,
try this:
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; }
Hi @danbp
I have made the modification but get same result: navigation missed and if I write the “/page/2” url have “Oops! That page can’t be found.” message
Best regards
? no idea. Here what is working for me: https://gist.github.com/chouf1/342c08eb8be9432ae97f
for posts and comments on 2 sub tabs
Note that the comment pagination doesn’t work for post pagination, so the’re 2 different techniques in useHi @danbp
I have added your code as plugin on my new test site. On this site have activated only 2 plugins: buddypress and your code.
This is what I see on the “My posts” tab (there is no navigation):
I would like to display only one tab with the posts of the displayed user, without subtabs.
I would like to display only one tab… simply remove the code used for comments.
Have you more than 3 posts (my per_page setting is 3 by “page”), so pagination can show up ? And have you tested with a Twenty theme. I tested succesfully the code on 2012 via bp-custom, not as plugin (if it makes a difference)…Hi @danbp
I think I have done the same configuration as you, but don’t work for me. Could be possible thar your code not work with the new version of Buddypress?
This are my posts:
This is that I see with
'posts_per_page' => 2,
:
Before, I have tested with Twenty Thirteen, Now I’m testing with Twenty Fifteen theme.
I have created a bp-custom.php file on plugins/ folder and deleted my previous plugin.
The only plugin I have active is Buddypress:
—
I would like to display only one tab with the posts of the displayed user, without subtabs. My goal is remove “My posts” and “My Comments”. I would like to display the posts inside the “Contributions” tabI have solved this problem with a new paged param. I send my plugin if is useful for somebody.
The plugin first check if the user is author on any post. Then displays the post of the author on a new tab.
Best regards.
- The topic ‘Pagination gives error on buddypress tab’ is closed to new replies.