✏️ 正在编辑: single.php
路径:
/home/h359620/public_html/wp-content/themes/datis/template-parts/blog/single/single.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php if (!defined('ABSPATH')) exit; $extras = Datis_Theme_Extras::get_instance(); $meta_bar = $extras->get_post_meta_bar_data(); $cats = $extras->get_post_categories(); $tags = $extras->get_post_tags(); $current_id = get_the_ID(); $current_cats = wp_get_post_categories($current_id); $related_query = null; if (! empty($current_cats)) { $args = [ 'post_type' => 'post', 'posts_per_page' => 3, 'post__not_in' => [$current_id], 'ignore_sticky_posts' => true, 'category__in' => $current_cats, ]; $related_query = new WP_Query($args); } if (! $related_query || ! $related_query->have_posts()) { if ($related_query instanceof WP_Query) { wp_reset_postdata(); } $fallback_args = [ 'post_type' => 'post', 'posts_per_page' => 3, 'post__not_in' => [$current_id], 'ignore_sticky_posts' => true, 'orderby' => 'rand', ]; $related_query = new WP_Query($fallback_args); } $demo = get_option('datis_active_demo'); $heading_icon = ''; if ($demo === 'business') : $heading_icon = '<svg width="18" height="69" viewBox="0 0 18 69" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M9 19.8558L10.8558 18L9 16.1442L7.14423 18L9 19.8558ZM9 18L9.32143 18L9.32143 -1.40501e-08L9 0L8.67857 1.40501e-08L8.67857 18L9 18Z" fill="#0A2647" fill-opacity="0.2"/> <path d="M0.322266 39.2267C0.322266 40.7192 1.53224 41.9292 3.02481 41.9292H14.1728C15.6654 41.9292 16.8753 40.7192 16.8753 39.2267V35.7801C16.8753 34.0703 15.3076 32.7902 13.6324 33.1321L2.48441 35.4072C1.22608 35.664 0.322266 36.7709 0.322266 38.0552V39.2267Z" fill="#0A2647"/> <path d="M16.875 28.4159C16.875 26.9233 15.665 25.7134 14.1725 25.7134H3.02447C1.53189 25.7134 0.321926 26.9233 0.321926 28.4159V31.8625C0.321926 33.5722 1.88964 34.8523 3.56487 34.5105L14.7129 32.2354C15.9712 31.9786 16.875 30.8717 16.875 29.5874V28.4159Z" fill="var(--datis-primary-color)"/> <path d="M9 48.2868L10.8558 50.1426L9 51.9983L7.14423 50.1426L9 48.2868ZM9 50.1426L9.32143 50.1426L9.32143 68.1426L9 68.1426L8.67857 68.1426L8.67857 50.1426L9 50.1426Z" fill="#0A2647" fill-opacity="0.2"/> </svg>'; elseif ($demo === 'industry') : $heading_icon = '<svg width="5" height="62" viewBox="0 0 5 62" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M0 0C2.76142 0 5 2.23858 5 5V57C5 59.7614 2.76142 62 0 62V0Z" fill="var(--datis-secondary-color)"/> </svg>'; else : $heading_icon = '<svg width="84" height="15" viewBox="0 0 84 15" fill="none" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_633_2489)"> <rect width="84" height="15" rx="7.5" fill="var(--datis-primary-color)"/> <rect x="-10" width="75" height="15" rx="7.5" fill="var(--datis-secondary-color)"/> </g> <defs> <clipPath id="clip0_633_2489"> <rect width="84" height="15" rx="7.5" fill="white"/> </clipPath> </defs> </svg>'; endif; $approved_count = get_comments_number(get_the_ID()); $style_map = [ 'architecture' => '1', 'business' => '2', 'industry' => '3', ]; $style = $style_map[$demo] ?? '1'; $q = new WP_Query([ 'post_type' => 'post', 'posts_per_page' => 4, 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'no_found_rows' => true, 'post__not_in' => [get_the_ID()], ]); ?> <div class="container blog-single blog-single <?php echo $demo; ?>-demo pt-3"> <div class="blog-wrapper d-flex flex-column-reverse flex-lg-row align-items-start justify-content-between gap-3 gap-lg-0 mt-3 mt-lg-5"> <div class="col-12 col-lg-9 blog-content"> <h1 class="blog-title"> <svg width="36" height="6" viewBox="0 0 36 6" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="36" height="6" rx="3" fill="var(--datis-primary-color)" /> </svg> <?php the_title(); ?> </h1> <div class="the-post-thumbnail"> <?php if (has_post_thumbnail()) : the_post_thumbnail(); else: ?> <img src="https://placehold.co/900x480" alt="<?php the_title(); ?>"> <?php endif; ?> </div> <div class="post-meta d-flex flex-column flex-lg-row align-items-lg-center align-items-flex-start justify-content-between"> <div class="meta-item author"> <img src="<?php echo $meta_bar['author']['avatar_url']; ?>" alt="<?php echo $meta_bar['author']['name']; ?>"> <span><?php echo $meta_bar['author']['name']; ?></span> </div> <svg width="1" height="24" viewBox="0 0 1 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="1" height="24" fill="#090625" fill-opacity="0.16" /> </svg> <div class="meta-item date"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M22 12C22 17.52 17.52 22 12 22C6.48 22 2 17.52 2 12C2 6.48 6.48 2 12 2C17.52 2 22 6.48 22 12Z" stroke="var(--datis-primary-color)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> <path d="M15.7109 15.18L12.6109 13.33C12.0709 13.01 11.6309 12.24 11.6309 11.61V7.51001" stroke="var(--datis-primary-color)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span><?php echo $meta_bar['date_label']; ?></span> </div> <svg width="1" height="24" viewBox="0 0 1 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="1" height="24" fill="#090625" fill-opacity="0.16" /> </svg> <div class="meta-item views"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M15.5799 11.9999C15.5799 13.9799 13.9799 15.5799 11.9999 15.5799C10.0199 15.5799 8.41992 13.9799 8.41992 11.9999C8.41992 10.0199 10.0199 8.41992 11.9999 8.41992C13.9799 8.41992 15.5799 10.0199 15.5799 11.9999Z" stroke="var(--datis-primary-color)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> <path d="M11.9998 20.27C15.5298 20.27 18.8198 18.19 21.1098 14.59C22.0098 13.18 22.0098 10.81 21.1098 9.39997C18.8198 5.79997 15.5298 3.71997 11.9998 3.71997C8.46984 3.71997 5.17984 5.79997 2.88984 9.39997C1.98984 10.81 1.98984 13.18 2.88984 14.59C5.17984 18.19 8.46984 20.27 11.9998 20.27Z" stroke="var(--datis-primary-color)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span><?php echo $meta_bar['views_label']; ?></span> </div> <svg width="1" height="24" viewBox="0 0 1 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="1" height="24" fill="#090625" fill-opacity="0.16" /> </svg> <div class="meta-item reading-time"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M20.75 13.25C20.75 18.08 16.83 22 12 22C7.17 22 3.25 18.08 3.25 13.25C3.25 8.42 7.17 4.5 12 4.5C16.83 4.5 20.75 8.42 20.75 13.25Z" stroke="var(--datis-primary-color)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> <path d="M12 8V13" stroke="var(--datis-primary-color)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> <path d="M9 2H15" stroke="var(--datis-primary-color)" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round" /> </svg> <span><?php echo $meta_bar['reading_time_label']; ?></span> </div> </div> <div class="the-content"> <?php the_content(); ?> </div> <div class="post-cat"> <?php if ($cats) : ?> <p><?php _e('Categories:', 'datis'); ?></p> <?php endif; foreach ($cats as $cat) { echo '<a href="' . esc_url($cat['url']) . '">' . esc_html($cat['name']) . '</a>'; } ?> </div> <div class="separator"></div> <div class="post-tags"> <?php if ($tags) : ?> <p><?php _e('Tags:', 'datis'); ?></p> <?php endif; foreach ($tags as $tag) { echo '<span>' . esc_html($tag['name']) . '</span>'; } ?> </div> </div> <div class="col-12 col-lg-3 sidebar"> <h3 class="sidebar-title mb-4"> <?php _e('Related', 'datis') ?> <span><?php _e('news', 'datis') ?></span> </h3> <?php if ($related_query->have_posts()) : ?> <div class="datis-related-posts"> <?php while ($related_query->have_posts()) : $related_query->the_post(); get_template_part('template-parts/blog/content/blog-content', '4'); endwhile; ?> </div> <?php endif; wp_reset_postdata(); ?> </div> </div> <?php if ($approved_count > 0) : ?> <div class="blog-comments mt-5 pt-5"> <div class="heading d-flex flex-row justify-content-between align-items-center gap-3 mb-4"> <?php if ($demo === 'business' || $demo === 'industry') : ?> <div class="d-flex flex-row align-items-center gap-3"> <?php else : ?> <div class="d-flex flex-column align-items-start gap-3"> <?php endif; ?> <?php echo $heading_icon; ?> <div class="d-flex flex-column"> <?php if ($demo === 'industry') : ?> <p> <?php printf( wp_kses_post(__("%s Reviews", 'datis')), '<span class="accent-text">' . esc_html__("User'", 'datis') . '</span>' ); ?> </p> <span><?php esc_html_e('Real Feedback from Our Loyal Partners', 'datis'); ?></span> <?php elseif ($demo === 'architecture') : ?> <span>REVIEWS</span> <p><?php esc_html_e("User Reviews", 'datis'); ?></p> <?php else : ?> <p><?php esc_html_e("User Reviews", 'datis'); ?></p> <span><?php esc_html_e('REVIEWS', 'datis'); ?></span> <?php endif; ?> </div> </div><!-- /layout div --> <?php if ($demo === 'business' || $demo === 'industry') : ?> <svg class="d-none d-lg-flex" width="850" height="6" viewBox="0 0 950 6" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M-3.26633e-05 2.88672L2.88672 5.77347L5.77347 2.88672L2.88672 -3.26633e-05L-3.26633e-05 2.88672ZM2.88672 2.88672V3.38672H949.887V2.88672V2.38672H2.88672V2.88672Z" fill="#0A2647" fill-opacity="0.1" /> </svg> <?php endif; ?> </div><!-- /.heading --> <?php datis_comments_list(); ?> </div><!-- /.project-comments --> <?php endif; ?> <div class="blog-comment-form mt-5 pt-5"> <div class="heading d-flex flex-row justify-content-between align-items-center gap-3 mb-4"> <?php if ($demo === 'business' || $demo === 'industry') : ?> <div class="d-flex flex-row align-items-center gap-3"> <?php else : ?> <div class="d-flex flex-column align-items-start gap-3"> <?php endif; ?> <?php echo $heading_icon; ?> <div class="d-flex flex-column"> <?php if ($demo === 'industry') : ?> <p> <?php printf( wp_kses_post(__("%s Reviews", 'datis')), '<span class="accent-text">' . esc_html__("User'", 'datis') . '</span>' ); ?> </p> <span><?php esc_html_e('Real Feedback from Our Loyal Partners', 'datis'); ?></span> <?php elseif ($demo === 'architecture') : ?> <span>REVIEWS</span> <p><?php esc_html_e("User Reviews", 'datis'); ?></p> <?php else : ?> <p><?php esc_html_e("User Reviews", 'datis'); ?></p> <span><?php esc_html_e('REVIEWS', 'datis'); ?></span> <?php endif; ?> </div> </div><!-- /layout div --> <?php if ($demo === 'business' || $demo === 'industry') : ?> <svg class="d-none d-lg-flex" width="850" height="6" viewBox="0 0 950 6" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M-3.26633e-05 2.88672L2.88672 5.77347L5.77347 2.88672L2.88672 -3.26633e-05L-3.26633e-05 2.88672ZM2.88672 2.88672V3.38672H949.887V2.88672V2.38672H2.88672V2.88672Z" fill="#0A2647" fill-opacity="0.1" /> </svg> <?php endif; ?> </div><!-- /.heading --> <div class="col-12 col-lg-9" id="respond"> <?php datis_comments_form(); ?> </div> </div><!-- /.project-comments --> <div class="recent-blog mt-5 pt-5"> <div class="heading d-flex flex-row justify-content-between align-items-center gap-3 mb-4"> <?php if ($demo === 'business' || $demo === 'industry') : ?> <div class="d-flex flex-row align-items-center gap-3"> <?php else : ?> <div class="d-flex flex-column align-items-start gap-3"> <?php endif; ?> <?php echo $heading_icon; ?> <div class="d-flex flex-column"> <?php if ($demo === 'industry') : ?> <p> <?php printf( wp_kses_post(__("%s Blog Posts", 'datis')), '<span class="accent-text">' . esc_html__("Latest ", 'datis') . '</span>' ); ?> </p> <span><?php esc_html_e('Fresh insights from our blog', 'datis'); ?></span> <?php elseif ($demo === 'architecture') : ?> <span>Latest Blog Posts</span> <p><?php esc_html_e("Latest Blog Posts", 'datis'); ?></p> <?php else : ?> <p><?php esc_html_e("Latest Blog Posts", 'datis'); ?></p> <span><?php esc_html_e('Fresh insights from our blog', 'datis'); ?></span> <?php endif; ?> </div> </div><!-- /layout div --> <?php if ($demo === 'business' || $demo === 'industry') : ?> <svg class="d-none d-lg-flex" width="850" height="6" viewBox="0 0 950 6" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M-3.26633e-05 2.88672L2.88672 5.77347L5.77347 2.88672L2.88672 -3.26633e-05L-3.26633e-05 2.88672ZM2.88672 2.88672V3.38672H949.887V2.88672V2.38672H2.88672V2.88672Z" fill="#0A2647" fill-opacity="0.1" /> </svg> <?php endif; ?> </div><!-- /.heading --> <div class="d-flex flex-column flex-lg-row align-items-center justify-content-between gap-2"> <?php if ($q->have_posts()) : ?> <?php while ($q->have_posts()) : $q->the_post(); ?> <?php get_template_part('template-parts/blog/content/blog-content', $style); ?> <?php endwhile; wp_reset_postdata(); ?> <?php endif; ?> </div> </div> </div>
💾 保存文件
← 返回文件管理器