portfolio-page.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Template Name: Portfolio Page
  4. *
  5. * This page template displays a feautred project section followed by a collection of projects thumbnails.
  6. * If no featutred projects exists, only a collection of projects thumbnails is displayed.
  7. *
  8. * @link https://codex.wordpress.org/Template_Hierarchy
  9. *
  10. * @package Rebalance
  11. */
  12. get_header(); ?>
  13. <div id="primary" class="content-area">
  14. <?php
  15. /*
  16. * Include the Featured Project loop.
  17. * - if featured posts exist, collect their IDs and exclude them from the main loop
  18. */
  19. if ( rebalance_has_featured_projects( 1 ) ) {
  20. $featured_ids = rebalance_get_featured_project_ids();
  21. get_template_part( 'template-parts/section', 'featured' );
  22. } else {
  23. $featured_ids = null;
  24. } ?>
  25. <main id="main" class="site-main" role="main">
  26. <?php // Set Up New Query
  27. if ( get_query_var( 'paged' ) ) :
  28. $paged = get_query_var( 'paged' );
  29. elseif ( get_query_var( 'page' ) ) :
  30. $paged = get_query_var( 'page' );
  31. else :
  32. $paged = 1;
  33. endif;
  34. $posts_per_page = get_option( 'jetpack_portfolio_posts_per_page', '10' );
  35. $temp = null;
  36. $project_query = $temp;
  37. $project_query = new WP_Query();
  38. $project_query->query( array(
  39. 'post_type' => 'jetpack-portfolio',
  40. 'paged' => $paged,
  41. 'posts_per_page' => $posts_per_page,
  42. 'post__not_in' => $featured_ids
  43. ) ); ?>
  44. <?php if ( $project_query->have_posts() ) : ?>
  45. <div id="infinite-wrap">
  46. <?php /* Start the Loop */ ?>
  47. <?php while ( $project_query->have_posts() ) : $project_query->the_post(); ?>
  48. <?php
  49. /*
  50. * Include the Card template for the project content.
  51. */
  52. get_template_part( 'template-parts/content', 'card' );
  53. ?>
  54. <?php endwhile; ?>
  55. </div>
  56. <?php rebalance_paging_nav( $project_query->max_num_pages ); ?>
  57. <?php else : ?>
  58. <?php get_template_part( 'template-parts/content', 'none' ); ?>
  59. <?php endif; ?>
  60. <?php // Empty queries
  61. $project_query = $temp;
  62. $temp = null; ?>
  63. <?php // Reset posts so our normal loop isn't affected
  64. wp_reset_postdata(); ?>
  65. </main><!-- #main -->
  66. </div><!-- #primary -->
  67. <?php get_sidebar(); ?>
  68. <?php get_footer(); ?>