Advertisement
scanthe17

post-type-hero.php

Jul 26th, 2018
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. <?php
  2. /**
  3. * The template used for displaying hero content
  4. *
  5. * @package Catch_Wheels
  6. */
  7. ?>
  8.  
  9. <?php
  10.  
  11. $type = get_theme_mod( 'catch_wheels_hero_content_type', 'page' );
  12.  
  13. if ( 'page' === $type && $id = get_theme_mod( 'catch_wheels_hero_content' ) ) {
  14. $args['page_id'] = absint( $id );
  15. } elseif ( 'post' === $type && $id = get_theme_mod( 'catch_wheels_hero_content_post' ) ) {
  16. $args['p'] = absint( $id );
  17. } elseif ( 'category' === $type && $cat = get_theme_mod( 'catch_wheels_hero_content_category' ) ) {
  18. $args['cat'] = absint( $cat );
  19. $args['posts_per_page'] = 1;
  20. }
  21.  
  22. // If $args is empty return false
  23. if ( empty( $args ) ) {
  24. return;
  25. }
  26.  
  27. // Create a new WP_Query using the argument previously created
  28. $hero_query = new WP_Query( $args );
  29. if ( $hero_query->have_posts() ) :
  30. while ( $hero_query->have_posts() ) :
  31. $hero_query->the_post();
  32. ?>
  33. <div id="hero-content" class="hero-content-wrapper section">
  34. <div class="wrapper">
  35. <div class="section-content-wrap">
  36. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  37. <?php if ( has_post_thumbnail() ) : ?>
  38. <div class="post-thumbnail">
  39. <a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail( 'catch-wheels-hero-content' ); ?></a>
  40. </div>
  41. <div class="entry-container">
  42. <?php else : ?>
  43. <div class="entry-container full-width">
  44. <?php endif; ?>
  45.  
  46. <?php
  47. if ( ! get_theme_mod( 'catch_wheels_disable_hero_content_title' ) ) {
  48. the_title( '<header class="entry-header"><h2 class="entry-title">', '</h2></header>' );
  49. echo get_the_date();
  50.  
  51. }
  52. ?>
  53.  
  54. <div class="entry-content">
  55. <?php
  56. $show_content = get_theme_mod( 'catch_wheels_hero_content_show', 'excerpt' );
  57.  
  58. if ( 'full-content' === $show_content ) {
  59. the_content();
  60. } elseif ( 'excerpt' === $show_content ) {
  61. echo '<p>' . get_the_excerpt() . '</p>';
  62. }
  63.  
  64. wp_link_pages( array(
  65. 'before' => '<div class="page-links"><span class="page-links-title">' . esc_html__( 'Pages:', 'catch-wheels-pro' ) . '</span>',
  66. 'after' => '</div>',
  67. 'link_before' => '<span class="page-number">',
  68. 'link_after' => '</span>',
  69. 'pagelink' => '<span class="screen-reader-text">' . esc_html__( 'Page', 'catch-wheels-pro' ) . ' </span>%',
  70. 'separator' => '<span class="screen-reader-text">, </span>',
  71. ) );
  72. ?>
  73. </div><!-- .entry-content -->
  74.  
  75. <?php if ( get_edit_post_link() ) : ?>
  76. <footer class="entry-footer">
  77. <div class="entry-meta">
  78. <?php
  79. edit_post_link(
  80. sprintf(
  81. /* translators: %s: Name of current post */
  82. esc_html__( 'Edit %s', 'catch-wheels-pro' ),
  83. the_title( '<span class="screen-reader-text">"', '"</span>', false )
  84. ),
  85. '<span class="edit-link">',
  86. '</span>'
  87. );
  88. ?>
  89. </div> <!-- .entry-meta -->
  90. </footer><!-- .entry-footer -->
  91. <?php endif; ?>
  92. </div><!-- .entry-container -->
  93. </article><!-- #post-## -->
  94. </div><!-- .section-content-wrap -->
  95. </div> <!-- Wrapper -->
  96. </div> <!-- hero-content-wrapper -->
  97. <?php
  98. endwhile;
  99.  
  100. wp_reset_postdata();
  101. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement