How to create pagination on archive.php template

The solution was surprisingly simple as you can see below. Thanks for your help @Sally CJ and @Tom J Nowell. <?php get_header(); ?> <!– PAGE INTRODUCTION –> <div class=”container”> <h1 class=”page_title”><?php the_archive_title(); ?></h1> </div> <!– PAGE CONTENTS –> <div class=”container”> <div class=”row”> <!– POSTS –> <?php if ( have_posts() ) : while ( have_posts() ) … Read more

Custom Taxonomy terms with latest post ordered by date pagination issue

to change the number of posts per page you can do it in the wp dashboard like in this picture This function on functions.php works for me function tcPostsPerPage( $query ) { if (is_home()){$query->set(‘posts_per_page’, 6);} if (is_archive()){$query->set(‘posts_per_page’, 6);} } add_action( ‘pre_get_posts’, ‘tcPostsPerPage’ ); the two 6 is limiting to 6 per page, if this doest … Read more

Display different number of posts from one category on the different pages

You can check for the existence of a variable, so you don’t overwrite it: add_action( ‘pre_get_posts’, ‘wpse7262_pre_get_posts’ ); function wpse7262_pre_get_posts( &$wp_query ) { if ( $wp_query->is_category() ) { if ( ! array_key_exists( ‘post_type’, $wp_query->query_vars ) ) { $wp_query->set( ‘post_type’, ‘game’ ); } if ( ! array_key_exists( ‘posts_per_page’, $wp_query->query_vars ) ) { $wp_query->set( ‘posts_per_page’, 9 ); … Read more

category/category_name pagination 404 error

In the template used for category archives you should have no use for new WP_Query. For all the main templates that WordPress loads itself for post archives, WordPress has already queried the correct posts, so you don’t need to query them again with WP_Query. For these templates, it’s the template’s job just to display those … Read more

Fix custom query pagination without changing site-wide posts-per-page settings

I assume you have a custom post type: publication in functions.php place that code: function mk_parse_query($query) { if ($query->query_vars[‘post_type’] == ‘publication’)) { set_query_var( ‘posts_per_page’, 5 ); } } if( !is_admin() ) { add_filter(‘parse_query’,’mk_parse_query’); } Similar code works for me, but in my case I was struggling with 404 on custom taxonomies paged urls. Hope this … Read more

‘paged’ in wp_query doesn’t work

You set offset param, so paged param is ignored 😉 From Codex: offset (int) – number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged If you want to ignore most recent post in this query, you can achieve it in two ways. 1. Custom pagination. $ppp = get_option(‘posts_per_page’); … Read more

wp_link_page – wrap current page element

I wouldn’t use WordPress’ internal function. We had a very similar question recently: How to style current page number (wp_link_pages)? I wrote a small but flexible function to replace wp_link_pages(). It is probably easier to extend this than hacking around the return value of the native function.

Page navigation within a category

For this particular problem you need to change this.. <?php if ( $wp_query->max_num_pages > 1 ) : ?> For.. <?php if ( $my_query->max_num_pages > 1 ) : ?> However, like Rarst said, if you’re looking to change the “main” query, then query_posts is really what you’re looking for, and the change above wouldn’t be required … Read more

Pagination in plugin with custom post type

the_posts_pagination uses global query and global query does not have pagination. So it is the correct behavior of WordPress. To overcome from this problem assign custom query to global query then after looping again restore the global query. function foo($args){ $post_type = $args[‘post_type’]; global $wp_query; $original_query = $wp_query; $custom_post_type = new WP_Query( array( ‘post_type’ => … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)