Pagination formatting templates have no effect when used with GetPostsQuery
-
Hi
I’m having an issue with Pagination formatting templates (tpls) when used with the GetPostsQuery class.
I’ve pretty much copied and pasted the example code from the docs (but added in my post type, set a limit of 1 to see the pagination with just two posts, removed
[+extra+]
and put the word ‘TEST’ in the outerTpl formatting string.My template renders the pagination, but always with the default templates. Any ideas?
Code here…
<?php require_once(CCTM_PATH.'/includes/GetPostsQuery.php'); $Q = new GetPostsQuery(); // Define the query $args = array(); $args['post_type'] = array('event'); $args['limit'] = 1; $args['paginate'] = true; // Read the offset variable (VERY IMPORTANT!) if (isset($_GET['offset'])) { $args['offset'] = (int) $_GET['offset']; } $results = $Q->get_posts($args); foreach ($results as $r) { // print out a bit about each post in the result set... echo '<p>A result to go here</p>'; } // Pagination // Set formatting templates $tpls['prevTpl'] = '<a href="[+base_url+]&offset=[+offset+]">‹ Prev.</a> '; $tpls['nextTpl'] = ' <a href="[+base_url+]&offset=[+offset+]">Next ›</a>'; $tpls['currentPageTpl'] = ' <span>[+page_number+]</span> '; $tpls['pageTpl'] = ' <a href="[+base_url+]&offset=[+offset+]">[+page_number+]</a> '; $tpls['outerTpl'] = '<div id="pagination">[+content+]<br/> Page [+current_page+] of [+page_count+]<br/>Displaying TEST [+first_record+] thru [+last_record+] of [+record_count+]</div>'; $Q->set_tpls($tpls); print $Q->get_pagination_links(); ?>
Also note, I excluded
[+extra+]
from the strings as the example code only shows how to add this an instance of the CCTM_Pagination object, but not how to use this with GetPostsQuery. I attempted the following, but no joy…$args['extra'] = 'test';
before the call to$results = $Q->get_posts($args);
Thanks,
Jameshttp://wordpress.org/extend/plugins/custom-content-type-manager/
- The topic ‘Pagination formatting templates have no effect when used with GetPostsQuery’ is closed to new replies.