Change class=”page-numbers” in pagination

The paginate_links() function, located in wp-includes/general-template.php, doesn’t allow for certain parts of the HTML (such as the page-numbers class) to be customized. A simple string replacement will not work due to the way that the classes are generated, as highlighted in this excerpt of code from paginate_links(): $page_links[] = ‘<a class=”prev page-numbers” href=”‘ . esc_url( … Read more

How can I see all of a post’s comments on a single page as a reader, if pagination is enabled?

Just build a link that has some query args: printf( ‘<a href=”http://example.com/all-comments?pid=%s”>All comments</a>’ ,get_the_ID() ); Then add a page with a a permalink of all-comments, so you have something to target. There you attach a template like the following (just a base to work off): <?php /** * Template Name: All Comments */ // Abort … Read more

Single Page View for Paginated Posts

Yes, it is possible, and I use it on my own site. Here it is in action: my Settings API post is paginated, but can viewed on a single page, using the “Single-Page View” link. First, you need to prepare a custom query variable, e.g. in functions.php, add the following: function cbnet_parameter_queryvars( $qvars ) { … Read more

Next/Previous Links in same category

previous_post_link takes 5 params, but you use only 2 of them. Let’s take a look at other 3: in_same_term (boolean) (optional) Indicates whether previous post must be within the same taxonomy term as the current post. If set to ‘true’, only posts from the current taxonomy term will be displayed. If the post is in … Read more

Pagination: How do I always show ‘previous’?

Looking at the source of paginate_links() it seems there is no option available to always include a previous or next link. The function simply compares the current page number with the total page number to determine whether these links need to be added. Working around this problem is possible, though. This should get you started: … Read more

Strange paginate_links behavior. First page link is always whatever page I’m on, all other links are correct

Short answer: Try ‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ), ‘format’ => ‘?paged=%#%’, Long answer: I took a look at the paginate_links() source code (v3.5.1) and there is this line (#) $link = str_replace(‘%_%’, 1 == $n ? ” : $format, $base); that is giving you the empty first page link. … Read more