-
Ahmed, is there a way to get the posts by the user on their profile page? I guess their ID has got to be stored in a global variable on the profile page, so can I use that to modify the wordpress loop with query_posts?
<?php
$paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1;query_posts( array(???????????????????????), ‘paged’ => $paged, ) );
?>
Get me? 😀
Use this to get User ID dynamically on profile page 🙂
$user_id = userpro_get_view_user( get_query_var(‘up_username’) );
then use it like so ‘author’=> $user_id 😉
I can’t get it to work with pagination. :/
<?php
$user_id = userpro_get_view_user( get_query_var(‘up_username’) );
$paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1;
query_posts( array( ‘author’=> $user_id , ‘paged’ => $paged, ) );
?>
<?php if (have_posts()) : ?>
<?php while ( have_posts() ) : the_post() ?>
<?php
get_template_part( ‘standard-post’ );
?><?php endwhile;?>
<?php endif; ?>
Ok after some testing I’ve realised that I can’t paginate posts on the profile page properly.
For some reason it isn’t working with the Userpro permalink settings.
If I create a custom page template with that code and have the profile link be /profile-page/username it works fine, but as soon as I update the settings in userpro to that URL pagination fails.
Why is this??
Whatever page userpro is set as the profile page > pagination fails.
On other pages with the same template, pagination works.
I think so.
See if I take my template >
<?php
$user_id = userpro_get_view_user( get_query_var(‘up_username’) );
$paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1;
query_posts( array( ‘author’=> $user_id , ‘paged’ => $paged, ) );
?>
<?php if (have_posts()) : ?>
<?php while ( have_posts() ) : the_post() ?>
<?php if ( has_post_format( ‘video’ )) {
get_template_part( ‘video-post’ );
}elseif ( has_post_format( ‘image’ )) {
get_template_part( ‘image-post’ );
} else {
get_template_part( ‘standard-post’ );
}?>
<?php endwhile;?>
<?php endif; ?>
And create a page called ‘profile-page’ with userpro template [userpro template=view] in it, pagination works!
As soon as I go to userpro settings and update the page permalinks to use the slug profile-page, pagination fails again.
So, pagination works on the profile page UNLESS userpro is set to use that page slug as it’s profile page url, which is kind of annoying 😀
Yes. I think the problem is with custom rewrite rules that need to be added to profile/ page.
You must be logged in to reply to this topic.