Skip Navigation

[Résolu] position of pagination (using WP-PageNavi)

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.

This topic contains 4 réponses, has 2 voix.

Last updated by Daniel Il y a 6 années et 7 mois.

Assigned support staff: Minesh.

Auteur
Publications
#307704
pagination.png

I use the WP-PageNavi plugin for pagination as described here: https://toolset.com/forums/topic/url-rewriting-for-pagination/

I'd like to show the pagination below the content - the shortcode is placed below the loop - but I get it displayed on the top of the loop.

Any idea what is happening here?

#307742

Minesh
Supporter

Languages: Anglais (English )

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

Hello and thank you for contacting Toolset support.

1)
Could you please send me a link of your page where you have inserted your view with pagination.

2)
*** Please take FULL BACKUP of your database and your website.***
In order to investigate your issue if we require to check things on your install in order to see what could be going wrong there.

If you agree to this please use the form fields I have enabled below this comment box to provide temporary access details (wp-admin and FTP)?

I have set next reply as private.

#307761

Hello Minesh,

thanks for your update. I run the site on a local server. May you get an idea about the issue when reviewing the code I added to the functions.php as suggested by Caridad:

/**
 * 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');

add_filter('wpv_view_settings', 'ek_my_vs', 99, 2);
 
function ek_my_vs($settings, $id) {
    if ( $id = 7 ) { // change XXX to the View ID being used in the page on the homepage
        global $wp_query;
        $my_query_vars = $wp_query->query_vars;
        $paged = isset( $my_query_vars['page'] )  ? $my_query_vars['page'] : 1;
        $settings['paged'] = $paged;
    }
    return $settings;
}

May in that line:

add_action('pre_get_posts', 'pagenavi_paged');
#307885

Minesh
Supporter

Languages: Anglais (English )

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

Could you please try to replace your function 'wpv_pagenavi' with the following and check if it works:

function wpv_pagenavi($args, $content) {
global $WP_Views;
return wp_pagenavi( array('query' => $WP_Views->post_query, 'echo'=>false) );
}
#308004

Great, that works for me!