- fixed User Profile posts pagination;

- 2.0.29 release;
This commit is contained in:
nikitozzzzzzz
2018-10-08 23:36:05 +03:00
parent 846e9b3b5a
commit b4c2ff15dd
11 changed files with 246 additions and 149 deletions
+32 -40
View File
@@ -1,45 +1,37 @@
<?php $query_posts = UM()->query()->make('post_type=post&posts_per_page=10&offset=0&author=' . um_get_requested_user() );
<?php if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
//Only for AJAX loading posts
if ( ! empty( $posts ) ) {
foreach ( $posts as $post ) {
UM()->shortcodes()->set_args = array( 'post' => $post );
UM()->shortcodes()->load_template( 'profile/posts-single' );
}
}
} else {
if ( ! empty( $posts ) ) { ?>
<div class="um-ajax-items">
/**
* UM hook
*
* @type filter
* @title um_profile_query_make_posts
* @description Some changes of WP_Query Posts Tab
* @input_vars
* [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_profile_query_make_posts', 'function_name', 10, 1 ); ?>
* @example
* <?php
* add_filter( 'um_profile_query_make_posts', 'my_profile_query_make_posts', 10, 1 );
* function my_profile_query_make_posts( $query_posts ) {
* // your code here
* return $query_posts;
* }
* ?>
*/
UM()->shortcodes()->loop = apply_filters( 'um_profile_query_make_posts', $query_posts );
<?php foreach ( $posts as $post ) {
UM()->shortcodes()->set_args = array( 'post' => $post );
UM()->shortcodes()->load_template( 'profile/posts-single' );
}
if ( UM()->shortcodes()->loop->have_posts() ) {
if ( $count_posts > 10 ) { ?>
<div class="um-load-items">
<a href="javascript:void(0);" class="um-ajax-paginate um-button" data-hook="um_load_posts" data-author="<?php echo um_get_requested_user(); ?>" data-page="1" data-pages="<?php echo ceil( $count_posts / 10 ) ?>">
<?php _e( 'load more posts', 'ultimate-member' ); ?>
</a>
</div>
<?php } ?>
UM()->shortcodes()->load_template( 'profile/posts-single' ); ?>
<div class="um-ajax-items">
<!--Ajax output-->
<?php if ( UM()->shortcodes()->loop->found_posts >= 10 ) { ?>
<div class="um-load-items">
<a href="#" class="um-ajax-paginate um-button" data-hook="um_load_posts" data-args="post,10,10,<?php echo um_get_requested_user(); ?>"><?php _e('load more posts','ultimate-member'); ?></a>
</div>
</div>
<?php } ?>
</div>
<?php } else { ?>
<?php } else { ?>
<div class="um-profile-note"><span><?php echo ( um_profile_id() == get_current_user_id() ) ? __('You have not created any posts.','ultimate-member') : __('This user has not created any posts.','ultimate-member'); ?></span></div>
<?php } wp_reset_postdata(); ?>
<div class="um-profile-note">
<span>
<?php echo ( um_profile_id() == get_current_user_id() ) ? __( 'You have not created any posts.', 'ultimate-member' ) : __( 'This user has not created any posts.', 'ultimate-member' ); ?>
</span>
</div>
<?php }
}