Display “Page 3 of 5” for a paginated post

The current / total page count is set up by setup_postdata() which runs at the beginning of the loop. So, if you’re in the loop, all you have to do is this: global $page, $numpages; echo “Page $page of $numpages”; If you need to do that outside of the loop, do this first: global $page, … Read more

How to fix pagination after rewriting url? ie. www.site.com/players/type/pro/page/3/

You have to add another rule which maps the /page/# to the &paged=# variable. Really though, you’re kinda doing it all backwards here by filtering the rules array. Just calling add_rewrite_rule to add your rules makes a bit more sense. function plugin_name_add_rewrite_rules() { add_rewrite_rule(‘players/type/([^/]+)/?$’, ‘index.php?post_type=players&type=$matches[1]’, ‘top’); add_rewrite_rule(‘players/type/([^/]+)/page/([0-9]+)?$’, ‘index.php?post_type=players&type=$matches[1]&paged=$matches[2]’, ‘top’); } add_filter(‘init’, ‘plugin_name_add_rewrite_rules’);

post pagination names, not numbers

The text for <!–nextpage–> is hardcoded, so you can’t modify that specifically. wp_link_pages only works with consistent text, so I don’t think you can really make that do exactly what you want either, but it does accept a parameter echo which you can set to false to return the value. Leveraging that, there are plenty … Read more

Aggregate comments, with pagination

Most likely, the main thing that you missed is that you must have “Break comments into pages” checked in the Settings Discussion Subpanel. The pagination functions require this to be set, as do the URL rewrites. Here’s a working, complete page template to do what you’re asking: <?php /* Template Name: All Comments See http://wordpress.stackexchange.com/questions/63770/aggregate-comments-with-pagination … Read more

How to get the number of Pages in a single Post Pagination?

Inside the loop, as michael pointed out you could just refer to $numpages global variable. Outside of the loop, your code is almost fine. Being the number of the pages the number of <!–nextpage–> + 1, you could save a function call by doing: $numOfPages = 1 + substr_count($the_post->post_content, ‘<!–nextpage–>’); As a quick and not-that-dirty … Read more

add_rewrite_rule – working fine but broken for pagination

Have you tried: The main one: add_rewrite_rule( ‘region/([^/]+)/type/([^/]+)/?’, ‘index.php?taxonomy=region&term=$matches[1]&post_type=$matches[2]’, ‘top’ ); For pagination add_rewrite_rule( ‘region/([^/]+)/type/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?taxonomy=region&term=$matches[1]&post_type=$matches[2]&paged=$matches[3]’, ‘top’ ); Out of curiousity, I replaced one of the ([^/]+) with the literal ‘type’ since that doesn’t seem to be a dynamic variable. If the pagination doesn’t work, try switching the order of when it’s declared, i.e. before … Read more

how to get pagination link url?

If you check out the source, they’re both wrappers around *_posts(), which in turn are wrappers for get_*_posts_page_link() (where the wildcard indicates either next or previous). For example, next_posts() will echo or return the escaped URL, depending on the first argument: $escaped_url = next_posts( false /* Don’t echo */ ); next_posts(); // Prints escaped URL … Read more

Pagination resolving to first page only

Building off of what Rarst has said, I’m pretty sure the query string will retain ‘paged’ queries even if WP_Query strips it out as irrelevant. You could try replacing your query posts line with this: global $query_string; parse_str( $query_string, $my_query_array ); $paged = ( isset( $my_query_array[‘paged’] ) && !empty( $my_query_array[‘paged’] ) ) ? $my_query_array[‘paged’] : … Read more

How to add CSS Class to previous_post_link or get previous/next post link URL

You can use the more native function that is “below” the previous_/next_post_link();: # get_adjacent_post( $in_same_cat = false, $excluded_categories=””, $previous = true ) $next_post_obj = get_adjacent_post( ‘”https://wordpress.stackexchange.com/questions/17218/,”‘, false ); $next_post_ID = isset( $next_post_obj->ID ) ? $next_post_obj->ID : ”; $next_post_link = get_permalink( $next_post_ID ); $next_post_title=”&raquo;”; // equals “»” ?> <a href=”https://wordpress.stackexchange.com/questions/17218/<?php echo $next_post_link; ?>” rel=”next” class=”pagination pagination-link … Read more