Articles of pagination

WP_Query custom order and pagination

I am seeing some strange behaviour when combining a custom order with pagination when using WP_Query. The arguments for my query are as follows: $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 10, ‘meta_key’ => ‘news_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘paged’ => $my_page ); The variable $my_page contains the current page number as […]

Pagination for custom post types – url rewriting

I’m working with custom post type, that I want to paginate, here’s part of code, initializing custom post type: $args = array( ‘labels’ => $labels, ‘public’ => false, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘show_in_menu’ => true, ‘query_var’ => true, ‘capability_type’ => ‘post’, ‘has_archive’ => true, ‘hierarchical’ => false, ‘menu_position’ => null, ‘supports’ => array(‘title’, […]

Paging + WP Query

On every archive page I’m either using WP-queries and no paging, or paging without a WP-query and a regular old “if(have_posts)” Now on one archive page I want to display more than 8 posts (8 is in settings for all my normal archive pages) So I thought about using a WP-query, but when I use […]

Add pagination to a template loaded by query variable

I have set a query_var,called men, which loads a custom template displaying men’s clothes. The rewrite rule is as follows: add_rewrite_rule(‘collection/men/?$’,’index.php?post_type=collection&men=yes’,’top’); and the template redirect code is this: if(get_query_var(‘men’) && is_post_type_archive(array(‘collection’))){ add_filter(‘template_include’,function(){ return get_template_directory().’/clothes-men.php’; }); } The code works, rewrite working as expected ie. localhost/sample-site/collection/men loads the template. The problem comes when I add standard […]

Pagination with custom field

I’ve got a little (big) problem. Is there a solution to show only posts that have not the same custom field value (from a specific custom field key) ? I have some post with a manual ID as custom field, and I don’t want to show them into my loop, and keep a good pagination. […]

Pagination broken by naming conflict between CPT and Page

I have run into this issue before with pagination where your custom post type is called something like ‘insights’ and then the page that you create to display those custom posts in an archive is called ‘insights’ too. Straight away there is a naming conflict. When WordPress searches for the second page it actually searches […]

Translating a pager string

Most of WordPress function found in themes look like this: <?php echo get_next_posts_link( ‘Older posts’, $the_query->max_num_pages ); // display older posts link ?> <?php echo get_previous_posts_link( ‘Newer posts’ ); // display newer posts link ?> This works as expected. However, how can I rewrite this in order to translate it? I tried: <?php _e( echo […]

How to remove /page/2/ from home page?

First of all: I don’t understand the meaning or the action that http://myurl/page/2 does? I checked the Net tab in Firebug and saw that my page takes more than 3 seconds to load /page/2… but I don’t need pagination at my front page at all. I don’t get where it comes from either. My question: […]

Pagination, query more pages at once

I’m wondering if it is possible to do such thing on WordPress, I have an infinite scroll to display my posts, I’m keeping track the pages updating the url: and I have a code like that: if(isset($_GET[‘pag’])) { $paged = $_GET[‘pag’]; } else { $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; }; $args = […]

Custom pagination (Previous / Next)

So I’m working on a custom pagination following code: <?php if ($wp_query->max_num_pages > 1) : ?> <?php $next = get_next_posts_link( ‘Previous’, $the_query->max_num_pages ); $previous = get_previous_posts_link( ‘Next’ ); if(!empty($next)) { $links[] = ‘<li class=”previous”>’.$next.'</li>’; } if(!empty($previous)) { $links[] = ‘<li class=”next”>’.$previous.'</li>’; } if (!empty($links)) { ?> <nav class=”post-nav clear clearfix”> <ul><?php echo implode($links); ?> </ul> […]