Skip Navigation

[Resolved] url rewriting for pagination

This support ticket is created 9 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

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 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

This topic contains 5 replies, has 3 voices.

Last updated by Daniel 7 years, 10 months ago.

Assigned support staff: Caridad.

Author
Posts
#77797

Hi,

Do you think it's possible to create an url rewriting for the pagination of a view ?

I want to be sure that Google see all results and the website has a proper seo... by example :
hidden link
hidden link
etc.

instead of &wpv_column_sort_id=post_date&wpv_column_sort_dir=desc&wpv_view_count=1&wpv_paged=1

Thank you in advance for your answer,
Regards

#78126

Dear Emmanuel,

One way to do this is by using the WP-PageNavi plugin. You need to add the following code to functions.php in your theme:

// Get the page number into wp_pagenavi
function pagenavi_paged($q) {
  $types = (array)$q->get('post_type');
  if (in_array('test', $types)) {
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $q->set('paged', $paged);
  }
}
add_action('pre_get_posts', 'pagenavi_paged');
 
// Replace wpv-pagination shortcode
function wpv_pagenavi($args, $content) {
  global $WP_Views;
  wp_pagenavi( array('query' => $WP_Views->post_query) );
}
add_shortcode('wpv-pagination', 'wpv_pagenavi');

Remember to replace 'test' with your custom post type.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#78137

Hi,

Thank your for your precious answer 🙂

I don't use a custom post type... but if I delete the condition " if (in_array('test', $types)) {" it's work well for all my views with pagination (very good).

But now, maybe you could help me to add a last condition. The problem is I use somes Views with Ajax, and other Views with a static and manuel pagination.

I see with this script that when I want to use Ajax, this script make that Ajax don't work...

Maybe in your script you could add the possibility to load him for certain Views or add a condition to load him only if a views don't use Ajax.

It will be very perfect if we can do it 🙂

Best regards,
Emmanuel

#79485

Dear Emmanuel,

We need to change the code a little bit, like this:

// Get the page number into wp_pagenavi
function pagenavi_paged($q) {
if (get_query_var('paged')) {
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$q->set('paged', $paged);
}
}
add_action('pre_get_posts', 'pagenavi_paged');
 
// Add a custom wp_pagenavi shortcode
function wpv_pagenavi($args, $content) {
global $WP_Views;
wp_pagenavi( array('query' => $WP_Views->post_query) );
}
add_shortcode('wpv-pagenavi', 'wpv_pagenavi');

Instead of overwriting the wpv-pagination shortcode, we are creating a new one: wpv-pagenavi. This way you can use the original shortcode in your ajax pagination and replace the shortcode in your normal pagination to [wpv-pagenavi]

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#79686

Hi,

Woow 🙂 I love you CaridadZ 😀
It's work perfectly !
I think this is a good solution, it's a professionnal result, maybe it's could help someone else.
I'm happy and appreciate your support. Thank you !

Regards,
Emmanuel

#303591
Bildschirmfoto 2015-05-15 um 00.47.45.png

This was helpful for me too, thanks!
Anyway I have the pagination shown in top of the view even it is set below the loop.
Any idea what is happening here?