Custom next page link outside loop, access to paged variable – get_query_var?
I’ve been working for quite a few months on a redesign of http://createdigitalmusic.com – migrating from Mambo to WordPress in the process.
One of the features of our new template is little inter-post navigation links, as seen on http://treehugger.com/.
You can see my version on http://createdigitalmusic.com, they show up as little up and down arrows underneath the red date header box for each post.
When on a home template page they let you go up and down between posts, and when on a single page they are next_post and previous_post links. This is all good.
However, for the bottom post on pages using the home template, I’d like the Next button (down arrow) to point to the next page, so http://createdigitalmusic.com/page/2/.
Over several sessions of trying and forum searching I haven’t been able to achieve this.
I thought my problem may be something like this – http://wordpress.org/support/topic/57912 – as I use a custom query to run the loop twice. However I’m using a query like this:
<?php $my_query = new WP_Query('category_name=highlight&showposts=3');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_excerpt(); ?></a>
<?php endwhile; ?>
… in the header, followed by a normal loop to run the main posts.
I may have missed something very obvious, but I haven’t been able to get wordpress to create a link to the next page.
I was thinking I could just get php to create a “hardcoded” link to /page/#/, # being the current page number + 1, but I haven’t been able to find how to access the paged…
So, while writing that my brain put everything together and told me that I already did know how to access the paged variable, it’s mentioned in the forum topic I linked above. However it doesn’t seem to work as I expected. I’m using this:
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
Which from that topic seems like it should return “1” if query variable “paged” is empty, or another number if query variable “paged” has something in it. However for me it’s returning “1” every time.
Any pointers to fix this?
- The topic ‘Custom next page link outside loop, access to paged variable – get_query_var?’ is closed to new replies.