1

I have a blog page that calls posts with tag 'blog'. So i called a custom WP_query() object: $blog = new WP_query('tag=blog');.

The result works fine, but when i paginate the posts, the links always is shown even if doesn't exist more than 10 posts (the default limit).

How can i fix it?

1 Answer 1

1

just add the following code

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

then you query will be like as following

$blog = new WP_query('tag=blog&posts_per_page=10&paged=' . $paged);

Sign up to request clarification or add additional context in comments.

4 Comments

The paginations still there. I don't know if it helps, but i'm using get_next_posts_link to paginate.
which code you are using for pagination.can you put overhere?
<?php echo get_previous_posts_link(); ?> and <?php get_next_posts_link(); ?> just it
Please once check the with following code // get_next_posts_link() usage with max_num_pages echo get_next_posts_link( 'Older Entries', $blog->max_num_pages ); echo get_previous_posts_link( 'Newer Entries' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.