portfolio-page.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. // if password is required for this page, let's use the_content() to display the password form.
  16. if ( post_password_required() ) :
  17. the_content();
  18. else :
  19. /*
  20. * Include the Featured Project loop.
  21. * - if featured posts exist, collect their IDs and exclude them from the main loop
  22. */
  23. if ( rebalance_has_featured_projects( 1 ) ) {
  24. $featured_ids = rebalance_get_featured_project_ids();
  25. get_template_part( 'template-parts/section', 'featured' );
  26. } else {
  27. $featured_ids = null;
  28. }
  29. ?>
  30. <main id="main" class="site-main" role="main">
  31. <?php
  32. // Set Up New Query
  33. if ( get_query_var( 'paged' ) ) :
  34. $paged = get_query_var( 'paged' );
  35. elseif ( get_query_var( 'page' ) ) :
  36. $paged = get_query_var( 'page' );
  37. else :
  38. $paged = 1;
  39. endif;
  40. $posts_per_page = get_option( 'jetpack_portfolio_posts_per_page', '10' );
  41. $temp = null;
  42. $project_query = $temp;
  43. $project_query = new WP_Query();
  44. $project_query->query(
  45. array(
  46. 'post_type' => 'jetpack-portfolio',
  47. 'paged' => $paged,
  48. 'posts_per_page' => $posts_per_page,
  49. 'post__not_in' => $featured_ids,
  50. )
  51. );
  52. ?>
  53. <?php if ( $project_query->have_posts() ) : ?>
  54. <div id="infinite-wrap">
  55. <?php /* Start the Loop */ ?>
  56. <?php
  57. while ( $project_query->have_posts() ) :
  58. $project_query->the_post();
  59. ?>
  60. <?php
  61. /*
  62. * Include the Card template for the project content.
  63. */
  64. get_template_part( 'template-parts/content', 'card' );
  65. ?>
  66. <?php endwhile; ?>
  67. </div>
  68. <?php rebalance_paging_nav( $project_query->max_num_pages ); ?>
  69. <?php else : ?>
  70. <?php get_template_part( 'template-parts/content', 'none' ); ?>
  71. <?php endif; ?>
  72. <?php
  73. // Empty queries
  74. $project_query = $temp;
  75. $temp = null;
  76. ?>
  77. <?php
  78. // Reset posts so our normal loop isn't affected
  79. wp_reset_postdata();
  80. ?>
  81. </main><!-- #main -->
  82. <?php endif; // end post_password_required() ?>
  83. </div><!-- #primary -->
  84. <?php get_sidebar(); ?>
  85. <?php get_footer(); ?>