14

I was also searching for the same solution to use it with bootstrap pagination links, the below code is working 100% in my theme. function bittersweet_pagination() { global $wp_query; if ( $wp_query->max_num_pages <= 1 ) return; $big = 999999999; // need an unlikely integer $pages = paginate_links( array( 'base' => str_replace( $big, '...


13

EDIT - WORDPRESS 4.4.1 BUG Please take note that there is a bug in WordPress 4.4.1 (I'm not sure if this bug also influence WordPress 4.4, but according to the bug report, it does not) which fails pagination when setting a page as static front page. Be sure to check out the bug report (trac ticket #35344]) and the patch. This will be fixed in WordPress 4.4....


12

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 ...


11

paginate_links() doesn't offer a parameter and there are no hooks - see source - available to change the class(es). Which means you can do it like you have done it or you create your own pagination function based on paginate_links().


11

Not sure if you mean this kind of approach: add_filter( 'paginate_links', function( $link ) { return filter_input( INPUT_GET, 'from_expired' ) ? remove_query_arg( 'from_expired', $link ) : $link; } ); to remove the from_expired from the pagination links if it's in the current GET query.


9

I'm fairly certain this is answered elsewhere, but I'll add it here again. I believe your issue lies here: 'current' => max( 1, get_query_var('paged') ), Try this instead: global $wp_query; $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; ...then: 'current' => $current; Your 'base' may also ...


7

I'm assuming you want something like this: |---------------------| | content | | (static) | |---------------------| | gallery | | (paged) | |---------------------| | << pagelinks >> | |---------------------| In this setup your the post content stays the same, appears to be ...


7

Seems that the query string is coming from the base argument call to get_pagenum_link() so I have removed the query string component and re-add it with 'add_args'. Like so: <?php echo paginate_links(array( 'base' => preg_replace('/\?.*/', '/', get_pagenum_link(1)) . '%_%', 'current' => max(1, get_query_var('paged')), 'format' => '...


6

The wp_link_pages() function only shows either text or number, never both. If you take a look at the function's code, you'll see that there is no option to make it behave differently by passing parameters. That being said, there are three ways to do this without a plugin: Create your own function in your theme's functions.php file. Works, but then you'd ...


5

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. With your setup you ...


5

Just use your custom WP_Query/$works object to access the data in the paginate_links() arguments as well. paginate_links( array( 'base' => str_replace( 99999999, '%#%', esc_url( get_pagenum_link( 99999999 ) ) ), 'format' => '?paged=%#%', 'prev_text' => '', 'next_text' => '', 'current' => max( 1, $works->get( '...


5

for this you need to use type parameter $links = paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $posts_array->max_num_pages, 'prev_text' => __( 'Previous page', 'twentyfifteen' )...


5

Here's one suggestion: First we need to let paginate_links() return an array instead of a HTML list: 'type' => 'array', Then we can grab the output with: $paginate_links = paginate_links( $paginationArgs ); The plan is then to filter out the wanted links. Let's get the current value: $c = $paginationArgs['current']; We construct the search filter ...


3

Regarding the number of pages displayed, read through the arguments for paginate_links, specifically end_size and mid_size. As for the 404- The problem is there is no page 3. Whether or not a page returns content or loads the 404 template is based on the results of the main query, not your custom query you run in the template. If this is a page post type, ...


3

Try this, you can more customize it. But it should do as you wanted :-) function tp_link_pages() { global $page, $numpages; echo paginate_links( array( 'format' => get_permalink() . '%#%/', 'current' => $page, 'total' => $numpages ) ); }


3

You use your custom WP_Query to query posts, but then in pagination you use global $wp_query variable, which contains different query. You should use your custom query variable $works in your pagination, or change global $wp_query variable before your pagination function call. Since you use universal function to output pagination, second method will be ...


3

Static pages doesn't work with paged query variable, they need the page variable. This is the reason why your second code block makes the query work: it uses the page var when available. However, your paginated links code always use paged: ... 'format' => '?paged=%#%', ... So you are sending paged query var but looking for page var. Solution is to ...


3

There is no filter, but you can set the type argument to array when you call paginate_links(), and then you can run a filter on the returned array. Example: $links = array_map( function( $link ) { if ( FALSE === strpos( $link, '/page/' ) ) return str_replace( '<a ', '<a data-page="1" ', $link ); return preg_replace( ...


2

When creating custom lists of posts pagination won't happen automatically, you'll need to pass the pagination arguments into your get_posts call. The full details can be found on the WP_Query codex page. For the query you want to be paged you'll need to add something like 'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1; to your $args. ...


2

Between my phone and work some errors creeped in, sorry about that. here is my revised answer. Hope this helps in solving your problem. PROBLEM 1 You should not name your template 'archive-{$post_type}.php' if it is a page template. This totally goes against the template hierarchy for pages, and that is why your static frontpage doesn't work. From the ...


2

I think this is what you want. base is set via home_url(), format is page/%#%/, search query arg is added via add_args if it exists: $args = array( 'base' => home_url( '/%_%' ), 'format' => 'page/%#%/', 'current' => max( 1, get_query_var('paged') ), 'total' => $temp->max_num_pages, ); if( isset($_GET['s']) ){ $args['...


2

You have a few issues here The use of 'no_found_rows' => true is incorrect. no_found_rows is meant for queries that will not be paginated. 'no_found_rows' => true is passed by get_posts to WP_Query to legally "break" pagination, that is why get_posts cannot be paginated as normal. What is really happening here is, by default is, when you query the ...


1

$args = array( 'cat'=>7, 'offset'=>4,'paged' => $paged); in this array use posts_per_page insted of offset $args = array( 'cat' => 7, 'posts_per_page' => 4,'paged' => $paged);


1

There where one or two problems with the code that I sorted out Big changes $number_of_terms = count( get_terms( '100list' ) ); is replaced by $number_of_terms = wp_count_terms( '100list' );. The reason is that wp_count_terms is already there to return the term count natively get_categories is replaced by get_terms as get_terms accepts the offset ...


1

In your single.php add this example code inside the loop: <?php global $page; if ($page == 1) {?> <div style="color:red;">This text should only appear on first page of the post!!!</div> <?php } ?> you can change the div with your thing that you wanted to display only on the first post page..


1

There is no clean way to do this (that I notice from quick look at rather messy code of it), but $n_display is passed though formatting number_format_i18n() function which does have a filter. So you could try something like: function make_number_into_dot( $number ) { return 'o'; } add_filter( 'number_format_i18n', 'make_number_into_dot' ); // your ...


1

Change variable page to something else, page is a reserved keyword & whenever in url it found it convert url in to localhost/wordpress/page/2


1

If you've created a Custom Post Type, then WordPress should be able to handle this for you automagically. Check the Template Hierarchy. Instead of creating a "Page" and trying to paginate that, create archive-{post_type}.php instead. That file will be used as the index file for your CPT, and will show up automatically at http://yoursite.com/news. You've ...


1

if( wp_link_pages() ) does not make sense because the function is meant to produce result rather than check for condition and defaults to echoing said result. Applicability of using it like this aside, if( wp_link_pages('echo=0') ), or something along, that should silence that copy of output.


1

My suggestion is to build a custom function, based on the source code of paginate_links(). More specifically, you need to modify the following conditional checks so they ignore the current position and always display the link: if ( $prev_next && $current && 1 < $current ) for the "Previous" link and if ( $prev_next && $current &...


Only top voted, non community-wiki answers of a minimum length are eligible