Get the current page URL (including pagination)

In addition to Rajeev Vyas’s answer, you don’t need to pass any non-empty parameters to add_query_arg(). The following has always worked well for me: // relative current URI: $current_rel_uri = add_query_arg( NULL, NULL ); // absolute current URI (on single site): $current_uri = home_url( add_query_arg( NULL, NULL ) ); The function falls back on $_SERVER[ … Read more

Change the “page” slug in pagination

For some sites in German I use the following plugin to translate page to seite (the German word for page): <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Page to Seite * Description: Ersetzt <code>/page/</code> durch <code>/seite/</code>. * Author: Fuxia Scholz * License: MIT * License URI: http://www.opensource.org/licenses/mit-license.php */ if ( ! … Read more

Paged posts – how to use numbers and next/previous links?

The function you’re using, wp_link_pages­Codex, does not have the feature you’re looking for by default. However you can easily extend it by using a callback function, registered as a filter on that functions arguments: add_filter(‘wp_link_pages_args’, ‘wp_link_pages_args_prevnext_add’); The filter will then modify the parameters that are used in that function on-the-fly and inject the missing links … Read more

Change Posts per page count

This will do it: (add to your theme’s functions.php) add_action( ‘pre_get_posts’, ‘set_posts_per_page’ ); function set_posts_per_page( $query ) { global $wp_the_query; if ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_search() ) ) { $query->set( ‘posts_per_page’, 3 ); } elseif ( ( ! is_admin() ) && ( $query === $wp_the_query ) … Read more

How to determine if theres a next page

You can use get_previous_posts_link and get_next_posts_link to determine if they exists like this: $prev_link = get_previous_posts_link(__(‘&laquo; Older Entries’)); $next_link = get_next_posts_link(__(‘Newer Entries &raquo;’)); // as suggested in comments if ($prev_link || $next_link) { echo ‘<ul class=”navigation”>’; if ($prev_link){ echo ‘<li>’.$prev_link .'</li>’; } if ($next_link){ echo ‘<li>’.$next_link .'</li>’; } echo ‘</ul>’; } Hope This Helps

WP_Query Pagination on single-custom.php

You have 2 problems. First problem The line $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; will fail, because on singular post view, when the URL contains ‘/page/XX/’, the variable WordPress sets is ‘page’ and not ‘paged’. You may think to use ‘page’ instead of ‘paged’, but that will not … Read more