portfolio-page.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * Template Name: Portfolio Page Template
  4. *
  5. * @package Sketch
  6. */
  7. get_header(); ?>
  8. <div id="primary" class="content-area">
  9. <main id="main" class="site-main" role="main">
  10. <?php if ( sketch_has_featured_posts( 1 ) ) : ?>
  11. <div class="featured-content">
  12. <?php get_template_part( 'content-featured' ); ?>
  13. </div>
  14. <?php endif; ?>
  15. <?php if ( post_password_required() ) : ?>
  16. <?php the_title( '<header class="page-header"><h1 class="page-title">', '</h1></header>' ); ?>
  17. <div class="page-content">
  18. <?php the_content(); ?>
  19. </div><!-- .page-content -->
  20. <?php else : ?>
  21. <?php if ( ! get_theme_mod( 'sketch_hide_portfolio_page_content' ) ) : ?>
  22. <?php
  23. while ( have_posts() ) :
  24. the_post();
  25. ?>
  26. <?php the_title( '<header class="page-header"><h1 class="page-title">', '</h1></header>' ); ?>
  27. <div class="page-content">
  28. <?php
  29. the_content();
  30. wp_link_pages(
  31. array(
  32. 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'sketch' ) . '</span>',
  33. 'after' => '</div>',
  34. 'link_before' => '<span>',
  35. 'link_after' => '</span>',
  36. )
  37. );
  38. ?>
  39. <?php edit_post_link( __( 'Edit', 'sketch' ), '<div class="entry-meta"><span class="edit-link">', '</span></div>' ); ?>
  40. </div><!-- .page-content -->
  41. <?php endwhile; // end of the loop. ?>
  42. <?php endif; ?>
  43. <?php
  44. if ( get_query_var( 'paged' ) ) :
  45. $paged = get_query_var( 'paged' );
  46. elseif ( get_query_var( 'page' ) ) :
  47. $paged = get_query_var( 'page' );
  48. else :
  49. $paged = 1;
  50. endif;
  51. $posts_per_page = get_option( 'jetpack_portfolio_posts_per_page', '9' );
  52. $args = array(
  53. 'post_type' => 'jetpack-portfolio',
  54. 'paged' => $paged,
  55. 'posts_per_page' => $posts_per_page,
  56. );
  57. $project_query = new WP_Query( $args );
  58. if ( $project_query->have_posts() ) :
  59. ?>
  60. <div class="projects clear">
  61. <?php
  62. while ( $project_query->have_posts() ) :
  63. $project_query->the_post();
  64. get_template_part( 'content', 'portfolio' );
  65. endwhile;
  66. ?>
  67. </div><!-- .projects -->
  68. <?php
  69. sketch_paging_nav( $project_query->max_num_pages );
  70. wp_reset_postdata();
  71. ?>
  72. <?php else : ?>
  73. <section class="no-results not-found">
  74. <header class="page-header">
  75. <h1 class="page-title"><?php _e( 'No Project Found', 'sketch' ); ?></h1>
  76. </header><!-- .page-header -->
  77. <div class="page-content">
  78. <?php if ( current_user_can( 'publish_posts' ) ) : ?>
  79. <p><?php printf( __( 'Ready to publish your first project? <a href="%1$s">Get started here</a>.', 'sketch' ), esc_url( admin_url( 'post-new.php?post_type=jetpack-portfolio' ) ) ); ?></p>
  80. <?php else : ?>
  81. <p><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'sketch' ); ?></p>
  82. <?php endif; ?>
  83. </div><!-- .page-content -->
  84. </section><!-- .no-results -->
  85. <?php endif; ?>
  86. <?php endif; // end post_password_required() ?>
  87. </main><!-- #main -->
  88. </div><!-- #primary -->
  89. <?php get_footer(); ?>