| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * The template for displaying all single posts |
|---|
| 5 | * |
|---|
| 6 | * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post |
|---|
| 7 | * |
|---|
| 8 | * @package bridal_jewelry_store |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | get_header(); |
|---|
| 12 | ?> |
|---|
| 13 | <main id="primary" class="site-main"> |
|---|
| 14 | |
|---|
| 15 | <?php |
|---|
| 16 | while ( have_posts() ) : |
|---|
| 17 | the_post(); |
|---|
| 18 | get_template_part( 'template-parts/content', 'single' ); |
|---|
| 19 | |
|---|
| 20 | do_action( 'bridal_jewelry_store_post_navigation' ); |
|---|
| 21 | |
|---|
| 22 | if ( is_singular( 'post' ) ) { |
|---|
| 23 | $bridal_jewelry_store_related_posts_label = get_theme_mod( 'bridal_jewelry_store_post_related_post_label'); |
|---|
| 24 | $bridal_jewelry_store_cat_content_id = get_the_category( $post->ID )[0]->term_id; |
|---|
| 25 | $bridal_jewelry_store_related_posts_count = get_theme_mod( 'bridal_jewelry_store_related_posts_count'); |
|---|
| 26 | |
|---|
| 27 | $args = array( |
|---|
| 28 | 'cat' => $bridal_jewelry_store_cat_content_id, |
|---|
| 29 | 'posts_per_page' => $bridal_jewelry_store_related_posts_count, |
|---|
| 30 | ); |
|---|
| 31 | |
|---|
| 32 | $query = new WP_Query( $args ); |
|---|
| 33 | |
|---|
| 34 | if ( $query->have_posts() ) : |
|---|
| 35 | ?> |
|---|
| 36 | <div class="related-posts"> |
|---|
| 37 | <?php if ( get_theme_mod( 'bridal_jewelry_store_post_hide_related_posts', false ) === false ) : ?> |
|---|
| 38 | <h2><?php echo esc_html( $bridal_jewelry_store_related_posts_label ); ?></h2> |
|---|
| 39 | <div class="row"> |
|---|
| 40 | <?php |
|---|
| 41 | while ( $query->have_posts() ) : |
|---|
| 42 | $query->the_post(); |
|---|
| 43 | ?> |
|---|
| 44 | <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> |
|---|
| 45 | <div class="mag-post-single"> |
|---|
| 46 | <div class="mag-post-img"> |
|---|
| 47 | <?php bridal_jewelry_store_post_thumbnail(); ?> |
|---|
| 48 | </div> |
|---|
| 49 | <div class="mag-post-detail"> |
|---|
| 50 | <?php the_title( '<h5 class="entry-title mag-post-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h5>' ); ?> |
|---|
| 51 | <div class="mag-post-excerpt"> |
|---|
| 52 | <?php the_excerpt(); ?> |
|---|
| 53 | </div> |
|---|
| 54 | </div> |
|---|
| 55 | </div> |
|---|
| 56 | </article> |
|---|
| 57 | <?php |
|---|
| 58 | endwhile; |
|---|
| 59 | wp_reset_postdata(); |
|---|
| 60 | ?> |
|---|
| 61 | </div> |
|---|
| 62 | <?php endif; ?> |
|---|
| 63 | </div> |
|---|
| 64 | <?php |
|---|
| 65 | endif; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | // If comments are open or we have at least one comment, load up the comment template. |
|---|
| 69 | if ( comments_open() || get_comments_number() ) : |
|---|
| 70 | comments_template(); |
|---|
| 71 | endif; |
|---|
| 72 | |
|---|
| 73 | endwhile; // End of the loop. |
|---|
| 74 | ?> |
|---|
| 75 | |
|---|
| 76 | </main> |
|---|
| 77 | <?php |
|---|
| 78 | if ( bridal_jewelry_store_is_sidebar_enabled() ) { |
|---|
| 79 | get_sidebar(); |
|---|
| 80 | } |
|---|
| 81 | get_footer(); |
|---|