Below is my query_post() for a custom query.
Why is the_content() displaying my full post instead of just the part above the "more" comment tag?
Why does next_posts_link() not paging through to the rest of the result set? It keeps just displaying the first page. Is it becasue "next_posts_link()" only works when there is /tag/ in the url?
<?php
$myposts = query_posts('tag=dvds-science,dvds-nature&posts_per_page=15');
foreach($myposts as $post) :
setup_postdata($post);
?>
<div class="post" id="post-<?php the_ID(); ?>">
<h1><?php the_title(); ?></h1>
<div class="entry">
<?php the_content('Read more'); ?>
</div>
</div>
<?php endforeach; ?>
<br /><br />
<?php next_posts_link('Next Page »') ?>
I have the same problem like you, but the_content() can work, and next_posts_link() did not work.
my pagelate code is:
<?php query_posts('cat=8'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
...content...
<?php endwhile;?>
Which version of wordpress are you guys using? Some of the prev/next links are not working under specific circumstances has been reported.
I was having a similar problem - I am using query_posts() to display all but one category on my main page, and this was causing my next_posts_link() and previous_posts_link() functions to break.
The solution posted here fixed the problem:
http://wordpress.org/support/topic/57912#post-312858
Note however that my $paged/query_posts() is BEFORE the "if (have_posts()) :" line.
(I am running 2.5)
Well looks like the thread starter has found a solution somewhere else as well.
Great! I'm looking for this solution for many days.
WordPress codex said:
The query_posts function is intended to be used to modify the main page Loop only.
It is not intended as a means to create secondary Loops on the page.
If you want to create separate Loops outside of the main one, you should create separate WP_Query objects and use those instead.
In main page, I can use this:
query_posts("$query_string . "category_name=life&paged=$paged");
but it doesn't work in my custom Template page.
Now I use this:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php query_posts("category_name=life&paged=$paged"); ?>
It works well in my custom template page.
I'm not familiar with php. Now I foud create a WP_Query works well too.
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query("category_name=life&paged=$paged");
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php $wp_query = null; $wp_query = $temp;?>