How to get the Page Number of the Current Page in Single Post Pagination

For your single page, you could try using the global $page variable. Another alternative would be to try fetching the query page variable, with e.g.: $wpse_current_page = (int) get_query_var( ‘page’ ); if( $wpse_current_page > 0 ) { printf( __( ‘Page Number: %d’, ‘wpse-theme-slug’ ), (int) $wpse_current_page ); } on your single page.

WP_Query ajax loader detect end of posts

Page template: <div class=”entry-content”> <?php $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘2’, ‘paged’ => 1, ); $my_posts = new WP_Query($args); if ($my_posts->have_posts()) : ?> <div class=”my-posts”> <?php while ($my_posts->have_posts()) : $my_posts->the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_excerpt(); ?> <?php endwhile; ?> </div> <?php endif; ?> <div class=”loadmore”>Load More…</div> </div> Ajax … Read more

Pagination not applied on posts

The pagination isn’t working correctly because it assumes you want to paginate all results. You are simply hiding pages, by which time it’s too late to adjust the pagination. To fix this, you need to alter the query using the pre_get_posts filter. For example: function search_only_posts($query) { if($query->is_search) { $query->set(‘post_type’, ‘post’); } return $query; } … Read more

Setting posts per page in query_posts

Here’s what I usually use the pre_get_posts action to change a single query value for a taxonomy or category page: /** * Control the number of search results */ function custom_posts_per_page( $query ) { if ( $query->is_tax(‘mytaxonomy’) || $query->is_category(‘mycategory’) ) { set_query_var(‘posts_per_page’, 9); } } add_action( ‘pre_get_posts’, ‘custom_posts_per_page’ );

Insert pagination links – wp_link_pages() – before filters on posts

That’s because you have directly edited the single.php file, try to make a function and in it return wp_link_pages() and in add_action set a priority. Try this function function pagination_after_post() { return wp_link_pages(); } add_action(‘the_content’,’pagination_after_post’,1); My WP PHP is not that good, my function might be wrong, this is just an example, but this way … Read more

Pagination on single post page?

I know Twenty Eleven include this functionality by default and I’ve come to expect it as default behavior, so I hope I’m not missing something here. You should be able to add this to single.php by using the previous_post_link() and next_post_link() functions.

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