On which theme template file are you doing this?
Thread Starter
Adam
(@cscottrun)
single.php
At the bottom.
If I do:
previous_post_link();
I get a previous link for the post before the current one I am on.
The query on single.php returns a single post object that’s why the max_num_pages returns 0. What is it you want to do? Count all posts of the current post type?
Maybe try wp_count_posts().
or:
http://codex.ww.wp.xz.cn/Function_Reference/get_adjacent_post
Thread Starter
Adam
(@cscottrun)
No, pagination. I have already read the docs, but I only want it to show if there are more then one “page”
Edit:
I wanted it to show numbers. ONLY if there are more then one post or page.
I figured out that to get this too work it has to go on the index.php template >.>
How ever even with that fix it still doesn’t work, I have even looked at and copied how twenty eleven does it and still get nothing
You need to use next_posts_link() and previous_posts_link() on your index.php (extra “s” in the function name). If you want to have numbered pagination you could try the paginate_links() function or a plugin: http://ww.wp.xz.cn/extend/plugins/wp-pagenavi/
This is loop in wordpress:
$wp_query = new WP_Query();
$wp_query->query(‘category_name=’.$catname.’&showposts=5′.’&paged=’.$paged);
you can use $total_pages = $wp_query->max_num_pages;
Other examples:
$mypost=new WP_Query();
$mypost->query(‘cat=9&paged=$paged’);
while($chamngon->have_posts()):$chamngon->the_post();
<!– Show post –>
Endwhile;
Use $total_pages = $mypost->max_num_pages;
Note: The bold line