Hi all,
Using a custom query, I can't get the next_post_link() to work.
Query is built like this:
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$paged = get_query_var('paged');
$wp_query->query('showposts=1'.'&paged='.$paged.'&post_type=Nieuws');
while ($wp_query->have_posts()) : $wp_query->the_post();
$do_not_duplicate = $post->ID;
<-- does things -->
endwhile; ?>
<div class="contentnavigation">
» <?php previous_post_link(); ?>
» <?php next_post_link(); ?>
</div>
<?php $wp_query = null; $wp_query = $temp;?>
Any thought would be much appreciated!
Kharis Sulistiyono
Member
Posted 1 year ago #
Let me clarify your question. I do not get the clear point here. Do you want the post navigation working for custom post type (Nieuws) ?
next_post_link() is for single post nav;
try next_posts_link() http://codex.wordpress.org/Function_Reference/next_posts_link
Alchymyth: same deal, nothing happens.
Some clarification:
I'm displaying a news item through a custom post type query.
I want a link to the previous item, relative to the current one showing.
Kharis Sulistiyono
Member
Posted 1 year ago #
Try to use this :
[Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]
Let me know if the code works.
Kharis Sulistiyono
Member
Posted 1 year ago #
Sorry, I moved the code in pastebin. Try this : http://pastebin.com/GBzGVfV5
Let me know if the code is working.
kharisblank:
No, I only get the 'not found'.
Seems weird though to have 'if have posts' before doing a query. My guess it, it won't have posts yet. :-)
Solved. Had to be in the loop (in contradiction to pagination).