How to make WP Query Pagination work

try this: $the_query = new WP_Query( array(‘posts_per_page’=>12, ‘post_type’=>’customers_gallery’, ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1) ); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> //YOUR CONTENT YOU WANT TO SHOW <?php endwhile; $big = 999999999; // need an unlikely integer echo paginate_links( array( ‘base’ => str_replace( $big, ‘%#%’, get_pagenum_link( $big ) ), … Read more

Not refreshing content pagination on search result

Changed architecture and code a while. Simplified example: normal form, for example with search keyword inside some templete. <form method=”get” id=”search_form” action=”/results”> <input type=”text” name=”search_text” id=”search_text_input” placeholder=”Type something for search”> <button type=”submit”>GO</button> </form> After that i create results.php Here is code: <?php /* Template name: Custom Search */ get_header(); ?> <?php if($_GET[‘search_text’] && !empty($_GET[‘search_text’]) ) … Read more

How to use pagination on costum post type

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’=>’post’, // Your post type name ‘posts_per_page’ => 6, ‘paged’ => $paged,); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); // YOUR CODE endwhile; $total_pages = $loop->max_num_pages; if ($total_pages > 1){ $current_page = max(1, get_query_var(‘paged’)); echo … Read more

Post Pagination Customization (wp_link_pages) Editing Navigation

It makes all pages show “NEXT PAGE”, because you don’t tell it that it should be any different. What you need is to set that link conditionally based on which page is currently displayed: wp_link_pages( array( ‘before’ => ‘<div id=”slideshow”>’, ‘after’ => ‘</div>’, ‘next_or_number’ => ‘next’, ‘previouspagelink’ => ‘<span id=”previous” style=”display:none;”> PREVIOUS SLIDE </span>’, ‘nextpagelink’ … Read more

Homepage has Paged Pages that should not exist, like /page/2/ and on to /page/99999/

To remove relational links from the single post <head> use remove_action( ‘wp_head’, ‘adjacent_posts_rel_link_wp_head’ ); adjacent_posts_rel_link_wp_head documentation. To return Status 404 on paginated pages use .htaccess rule similar to following: RewriteRule ^page/([0-9]+)/$ http://yourdomain.tld/404/ [R=404,NC,L] .htaccess rule is not tested, but it gives you an idea.

wp_title() returns ‘page not found’ on page 2

Seems like the title was fetched before the query, and therefore didn’t fetch the custom posts. Had to add a pre_get_posts to my functions.php to make it work: add_filter( ‘pre_get_posts’, ‘my_get_posts’ ); function my_get_posts( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( ‘post_type’, array(‘theory’, ‘tasks’, ‘tutorials’, ‘video’, ‘interactive’) ); return $query; }

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