Pārlūkot izejas kodu

News archive added

Md Mozahidur Rahman 1 gadu atpakaļ
vecāks
revīzija
3c14396d99
2 mainītis faili ar 30 papildinājumiem un 91 dzēšanām
  1. 3 1
      css/theme-styles.css
  2. 27 90
      single-news.php

+ 3 - 1
css/theme-styles.css

@@ -1630,7 +1630,9 @@ body.archive aside#secondary{
   display: none;
 }
 
-
+.no-post-found {
+    margin: auto;
+}
 
 .portfolio-item {
 	border-bottom: 1px solid #999;

+ 27 - 90
single-news.php

@@ -57,112 +57,49 @@ get_header(); ?>
 
 
 			<section id="more-news" class="container">
-
 				<h2>In Other News</h2>
-				<div class="grid">
-					<div class="stub">
-
-						<div class="stub-img-holder">
-							<img class="stub-img" src="<?php echo (get_template_directory_uri()) ?>/img/campus_05.jpg" alt="">
-						</div>
-						<span class="news-date">January 1, 2023</span>
-
-						<a href="#">
-							<h3>Learning to make a museum more accessible</h3>
-						</a>
-
-
-					</div>
-
-					<div class="stub">
-						<div class="stub-img-holder">
-							<img class="stub-img" src="<?php echo (get_template_directory_uri()) ?>/img/campus_02.jpg" alt="">
-						</div>
-						<span class="news-date">January 1, 2023</span>
-
-
-
-						<a href="#">
-							<h3>New blood test to identify infections could reduce global antibiotic overuse</h3>
-						</a>
-
-
-					</div>
-
-					<div class="stub">
-						<div class="stub-img-holder">
-							<img class="stub-img" src="<?php echo (get_template_directory_uri()) ?>/img/gettybacktoschool.webp" alt="">
-						</div>
-						<span class="news-date">January 5, 2023</span>
-
-
-
-						<a href="#">
-							<h3>New center at addresses the forces shaping early childhood</h3>
-						</a>
-
-					</div>
-
+				<div class="parent-grid">
 
-				</div>
-
-				<div class="grid">
-					<div class="stub">
-
-						<div class="stub-img-holder">
-							<img class="stub-img" src="<?php echo (get_template_directory_uri()) ?>/img/campus_05.jpg" alt="">
-						</div>
-						<span class="news-date">January 1, 2023</span>
-
-						<a href="#">
-							<h3>Learning to make a museum more accessible</h3>
-						</a>
-
-
-					</div>
-
-					<div class="stub">
-						<div class="stub-img-holder">
-							<img class="stub-img" src="<?php echo (get_template_directory_uri()) ?>/img/campus_02.jpg" alt="">
-						</div>
-						<span class="news-date">January 1, 2023</span>
-
-
-						<a href="#">
-							<h3>New blood test to identify infections could reduce global antibiotic overuse</h3>
-						</a>
 
+					<?php
+					$args = array(
+						'post_type'      => 'news',
+						'posts_per_page' => 6,
+						'post__not_in' => array(get_the_ID()),
+						'orderby'        => 'date',
+						'order'          => 'DESC',
+					);
 
-					</div>
+					$query = new WP_Query($args);
 
-					<div class="stub">
-						<div class="stub-img-holder">
-							<img class="stub-img" src="<?php echo (get_template_directory_uri()) ?>/img/gettybacktoschool.webp" alt="">
-						</div>
-						<span class="news-date">January 5, 2023</span>
+					if ($query->have_posts()) :
+						while ($query->have_posts()) :
+							$query->the_post(); ?>
 
+							<div class="stub grid-sub-item">
+								<div class="stub-img-holder">
+									<img class="stub-img" src="<?php echo get_the_post_thumbnail_url() ?>" alt="">
+								</div>
+								<span class="news-date"><?php the_field('news_date'); ?></span>
 
+								<a href="<?php echo get_permalink(); ?>">
+									<h3><?php echo get_the_title(); ?></h3>
+								</a>
+							</div>
 
-						<a href="#">
-							<h3>New center at addresses the forces shaping early childhood</h3>
-						</a>
 
-					</div>
+					<?php
+						endwhile;
+					else :
+						echo '<div class="no-post-found">No related news has found! </div>';
+					endif; ?>
 
 
 				</div>
-
 			</section>
-
 		</div>
-
-
-
 	</main>
 
-
-
-
 <?php endwhile; ?>
 <style>
 	p {