Skip Navigation

[Closed] Custom views gets reset when paginate

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 1 year, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2778242

Jin

Tell us what you are trying to do?
I am trying to make Custom views persist when paginating

function sorting_modify_orderby( $view_args, $view_settings, $view_id, $default_paged = 1 ) {

global $filtered_post_ids;

if ( 8260 == $view_id ) { // Edit ID

// Ensure filtered_id_by_location is set and is a valid string
if ( isset($_GET['filtered_id_by_location']) && !empty($_GET['filtered_id_by_location']) ) {

// Convert the string of IDs into an array of integers
$ordered_ids = array_map('intval', explode(',', $_GET['filtered_id_by_location']));

// Log the IDs for debugging
error_log('lk-test custom_order_posts: Using filtered IDs: ' . implode(', ', $ordered_ids));

// Only modify the query if $ordered_ids is not empty
if (!empty($ordered_ids)) {
// Modify the view arguments to include only the posts with the specified IDs
$view_args['post__in'] = $ordered_ids;

// Set the orderby parameter to maintain the order of the specified IDs
$view_args['orderby'] = 'post__in';

// Handle pagination if a specific page is requested
if ( isset($_GET['paged']) && is_numeric($_GET['paged']) ) {
$view_args['paged'] = intval($_GET['paged']);
} else {
$view_args['paged'] = $default_paged;
}

} else {
error_log('lk-test custom_order_posts: No valid IDs after filtering');
}
} else {
error_log('lk-test custom_order_posts: filtered_id_by_location GET parameter not set or empty');
}
}

return $view_args;
}
add_filter( 'wpv_filter_query', 'sorting_modify_orderby', 101, 3 );

I have this code here that helps to update view when i run the function , it works fine but it resets the view when i paginate to the second page

This is my html for my pagination

<li class="wpv-pagination-nav-links-item js-wpv-pagination-nav-links-item page-item wpv-page-link-8260-2 js-wpv-page-link-8260-2">2

Is there any documentation that you are following?
no

Could you help me with this , i would just like to simply go to page 2 of the views while maintain the views_args

#2778307

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and tell me are you using ajax pagination or normal pagination?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] Custom views gets reset when paginate’ is closed to new replies.