-
-
Save BoweFrankema/c37844c56305aa2878c5 to your computer and use it in GitHub Desktop.
Template-loader.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="wefoster-testimonials-content"> | |
<?php | |
// Define custom query parameters | |
$custom_query_args = array( | |
'author' => bp_displayed_user_id(), | |
'post_type' => 'testimonials', | |
'posts_per_page' => 5, | |
'paged' => $paged, | |
); | |
// Get current page and append to custom query parameters array | |
$custom_query_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; | |
// Instantiate custom query | |
$custom_query = new WP_Query($custom_query_args); | |
// Pagination fix | |
$temp_query = $wp_query; | |
$wp_query = null; | |
$wp_query = $custom_query; | |
$my_template_loader = new Cue_Template_Loader; | |
$my_template_loader->get_template_part( 'testimonial-loop' ); | |
// Output custom query loop | |
if ($custom_query->have_posts()) : | |
while ($custom_query->have_posts()) : | |
$custom_query->the_post(); | |
?> | |
<?php do_action('before_content'); | |
?> | |
<?php echo $template['testimonial-loop']; ?> | |
<?php do_action('after_content'); | |
?> | |
<?php | |
endwhile; | |
endif; | |
// Reset postdata | |
wp_reset_postdata(); | |
// Custom query loop pagination | |
?> | |
<?php if (function_exists('wp_pagenavi')) : ?> | |
<?php wp_pagenavi(array('query' => $custom_query)); | |
?> | |
<?php else : ?> | |
<div class="alignleft"><?php next_posts_link(__('« Older Entries')); | |
?></div> | |
<div class="alignright"><?php previous_posts_link(__('Newer Entries »')); | |
?></div> | |
<?php endif; | |
?> | |
<?php | |
// Reset main query object | |
$wp_query = null; | |
$wp_query = $temp_query; | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment