dcoa
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.Thanks again guys, I actually didn’t get a chance to look at the last two posts above mine, were posted while I was writing my ‘Ok Fixed!’ anyone with the same problem as me might want to try those as well, but I am punching out, been trying to fix this for way too long.
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.Ok Fixed!
The problem was thatget_query_var('paged')doesn’t seem to work when a page template is used on a static page on the homepage, So you have to useget_query_var('page')instead, but for some reason having this being called after the$temp = $wp_query;value was redefined meant it didn’t return a value. So I just had to move it up so it was called before the custom value was defined. Working code for anyone with the same problem is:<?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('posts_per_page=5&cat=4&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?>Then:
<?php endwhile; ?>after the post.`
Then:
<?php $wp_query = null; $wp_query = $temp;?>
at the end.Full page code <a href=”http://pastebin.com/N0dEngEf”>here</a>
This
<?php print_r ($wp_query->query_vars); ?>was very useful in working out which variable was returning which value.Thanks keesiemeijer for your patience and help.
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.Sorry, still not working, I forgot I changed that back from the code you gave me, but just tried it with
$wp_query->query('posts_per_page=5&cat=4&paged='.$paged);back in and still the same problem.Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.Thanks, I did try with that in there but took it back out because it didn’t work, just put it back in to be sure and unfortunately still nothing.
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.I have tried removing everything in lines 13-28, to see if they were causing a problem, but that didn’t fix it.
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.I do have a bit of code that keeps the static page information at the top of the posts. I tried your suggestion as well as completely deleting the extra code, just leaving the bare bones of the loop and unfortunately it is still not working. Could it be something not on this page that is failing? Sorry to be such a trouble, I really do appreciate your help.
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.It is a static front page, I tried that code but unfortunately still nothing. I tried echoing the various values on the page and
get_query_var('page')returns nothing, no valueget_query_var('paged')returns “1” on both the first and second page.$paged returns 1 as well.
Would this mean that the code is right but something is amiss elsewhere?
also, If I change the else statement to
else { $paged = 2; }
It then loads only second page, and wont go back to the first, does this meant that the if and elseif statements aren’t being satisfied?thanks for your help so far
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.Additionally, If I echo $paged, It prints as “1” both on the first and second page, so that must be what the problem is. (Not sure if there is a better way to check that? like a trace statement or something?
Forum: Fixing WordPress
In reply to: query_posts() Pagination – tried all fixes, still can't work it out.Hi, Thanks for the reply, unfortunately still no luck, implemented your code as such:
<?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query->query("posts_per_page=5&cat=4&paged=".$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?>But no change to the problem, still the same thing on first and second page.