portfolio-page.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 ( ! get_theme_mod( 'sketch_hide_portfolio_page_content' ) ) : ?>
  16. <?php while ( have_posts() ) : the_post(); ?>
  17. <?php the_title( '<header class="page-header"><h1 class="page-title">', '</h1></header>' ); ?>
  18. <div class="page-content">
  19. <?php
  20. the_content();
  21. wp_link_pages( array(
  22. 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'sketch' ) . '</span>',
  23. 'after' => '</div>',
  24. 'link_before' => '<span>',
  25. 'link_after' => '</span>',
  26. ) );
  27. ?>
  28. <?php edit_post_link( __( 'Edit', 'sketch' ), '<div class="entry-meta"><span class="edit-link">', '</span></div>' ); ?>
  29. </div><!-- .page-content -->
  30. <?php endwhile; // end of the loop. ?>
  31. <?php endif; ?>
  32. <?php
  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', '9' );
  41. $args = array(
  42. 'post_type' => 'jetpack-portfolio',
  43. 'paged' => $paged,
  44. 'posts_per_page' => $posts_per_page,
  45. );
  46. $project_query = new WP_Query ( $args );
  47. if ( $project_query -> have_posts() ) :
  48. ?>
  49. <div class="projects clear">
  50. <?php
  51. while ( $project_query -> have_posts() ) : $project_query -> the_post();
  52. get_template_part( 'content', 'portfolio' );
  53. endwhile;
  54. ?>
  55. </div><!-- .projects -->
  56. <?php
  57. sketch_paging_nav( $project_query->max_num_pages );
  58. wp_reset_postdata();
  59. ?>
  60. <?php else : ?>
  61. <section class="no-results not-found">
  62. <header class="page-header">
  63. <h1 class="page-title"><?php _e( 'No Project Found', 'sketch' ); ?></h1>
  64. </header><!-- .page-header -->
  65. <div class="page-content">
  66. <?php if ( current_user_can( 'publish_posts' ) ) : ?>
  67. <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>
  68. <?php else : ?>
  69. <p><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'sketch' ); ?></p>
  70. <?php endif; ?>
  71. </div><!-- .page-content -->
  72. </section><!-- .no-results -->
  73. <?php endif; ?>
  74. </main><!-- #main -->
  75. </div><!-- #primary -->
  76. <?php get_footer(); ?>