Custom posts not paginating on archive page and returning 404

Your error is likely get_query_var(‘paged’) should be get_query_var(‘page’). However… You should avoid calling query_posts in the template, it is a waste of resources, as you’re just discarding the original query which has already happened. Hook pre_get_posts to instead alter the query before it happens: function wpa60728_pre_get_posts( $query ) { if ( ‘bvdirectory’ == get_post_type() && … Read more

Custom pagination code is not working

check below code for pagination. global $paged; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query( array(‘post_type’ => ‘post’,’posts_per_page’ => 2, ‘paged’ => $paged ) ); while (have_posts()) : the_post(); // Your post content. endwhile; echo paginate_links( $args ); global $wp_query; $big = 999999999; // need an unlikely integer echo paginate_links( array( ‘base’ => … Read more

Pagination issue in archive.php

You should not be setting the posts_per_page value in the template, nor should you be setting the object property directly after the query has run. That is going to cause the object data to become out of sync with itself. You need to alter that value with a filter on pre_get_posts. function pregp_archive_ppp_wpse_108225($qry) { if … Read more

Show content based on page number

Current post page can be detected using get_query_var(‘page’);. note that if you do not pass any page the page 1 is shown, but get_query_var(‘page’); will be 0; So in your function.php you can add: function get_page_image() { global $post; if ( ! is_object($post) || ! isset($post->ID) ) return; $page = get_query_var(‘page’); if ( empty($page) ) … Read more

How to paginate a list of child pages

Option 1: Personally I prefer this, because it gives you more options in the long run. Especially considering other setups involving a secondary query, take a look at my other answer I linked below. What you need to do is, make use of the paged parameter WP_Query offers. Additionally you have to setup a variable … Read more

How to use custom previous/next link ?

Do this to output only links for previous and next pages: <?php previous_posts_link ( ‘Previous’ ) ?> <?php next_posts_link ( ‘Next’ ); ?> Then add filters to your functions.php to add a class to each link: function next_posts_link_css ( $content ) { return ‘class=”next”‘; } add_filter( ‘next_posts_link_attributes’, ‘next_posts_link_css’ ); function previous_posts_link_css ( $content ) { … Read more

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