[Plugin: WP-PageNavi] PageNavi: Trying to filter out certain posts in loop from plugin navigation
-
Hey guys,
I’ve found this nice plugin, and now I need to make it work as I wish. I extract a date code from the titles of the posts in a “program” category, and I wish to show only those posts which have a datecode corresponding to a day AFTER today.
Now, I understand that to get PageNavi to work with a custom loop, we need to mess around with the $wp_query variable a bit, with code looking a bit like this
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
… and so on and so forth.This code throws a blank screen for me. It breaks my blog basically (yeah, I write it correctly). What is working is just attaching the query to $wp_query straight away.
This is my code ($currDateCode holds the date code of TODAY, as read from the server, getDateCode() reads the date code from the current post).
<?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : the_post(); if($currDateCode > getDateCode()) continue; ?> <div class="artist clearfix"> <a href="<?php the_permalink(); ?>"><img src="<?php viva('program',1);?>" /></a> <div class="tekst"> <h3><?php printMonoDate();?><span class="sep">|</span> <?php echo getPrice(); ?><span class="sep">|</span> <?php echo getKonsertstart(); ?></h3> <h2><a href="<?php the_permalink(); ?>"><?php printProgramTitle(); ?></a></h2> <?php echo get(event_intro);?> </div> </div> <?php endwhile; endif; ?>
This doesn’t work, because PageNavi picks up those posts which I try to skip with continue. Instead, they just display blank, but messing up the pagination.
I have tried as well to read out all the posts I desire to show in an include string ($include_string), but it seems that “include” is completely ignored in queries written in this way. In a normal get_posts query, it works fine, but then PageNavi breaks.
This doesn’t work in other words
$wp_query->query("category_name==program&orderby=title&order=ASC&showposts=5&include_string=104,110,120paged=$paged");
How can I get this working, so that my customized archive can go online? Tips and tricks greatly appreciated.
Thanks!
Eivind F S
- The topic ‘[Plugin: WP-PageNavi] PageNavi: Trying to filter out certain posts in loop from plugin navigation’ is closed to new replies.