Skip Navigation

[Resolved] url rewriting for pagination

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 5 respuestas, has 3 mensajes.

Last updated by Daniel hace 5 a帽os, 4 meses.

Assigned support staff: Caridad.

Autor
Mensajes
#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

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?